'디지털회로' 카테고리의 다른 글

20140508 인터럽트  (0) 2014.05.08
CDS  (0) 2014.05.07
20140425  (0) 2014.04.25
20140424 USART  (0) 2014.04.24
20144022 문자열 숫자, 출력하기  (0) 2014.04.22
by 날라차숑 2014. 4. 30. 15:50



'디지털회로' 카테고리의 다른 글

CDS  (0) 2014.05.07
20140430 ADC제어  (0) 2014.04.30
20140424 USART  (0) 2014.04.24
20144022 문자열 숫자, 출력하기  (0) 2014.04.22
20140421 LCD2  (0) 2014.04.21
by 날라차숑 2014. 4. 25. 11:16




'디지털회로' 카테고리의 다른 글

20140430 ADC제어  (0) 2014.04.30
20140425  (0) 2014.04.25
20144022 문자열 숫자, 출력하기  (0) 2014.04.22
20140421 LCD2  (0) 2014.04.21
20140417 LCD  (0) 2014.04.17
by 날라차숑 2014. 4. 24. 13:58

 #include <stdio.h>

#include "smart.h"

void inst_clear(void);
void inst_return(void);
void inst_entry(void);
void inst_display(void);
void inst_cursor(void);
void inst_function(void);
void data_a(void);
void lcd_init(void);

int main(void)
{

  lcd_init();
  data_a();
  data_a();
  data_a();
  data_a();
  data_a();
  

  
  while(1);
  {
  
  }        
  return 0;
}

void data_a(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E);
  DDRC = 0xFF;
  PORTA = (0<<PIN_E);

  PORTA=(1<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC='A';
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void lcd_init(void)
{
  volatile unsigned int uicnt;
  DELAY(500);
//  inst_function();
  lcd_inst(INST_FUNCTION);
//  inst_entry();
  lcd_inst(INST_ENTRY);
//  inst_cursor();
  lcd_inst(INST_CURSOR);
//  inst_display();
  lcd_inst(INST_DISPLAY);
//    inst_clear();
  lcd_inst(INST_CLEAR);
//  inst_return();
  lcd_inst(INST_RETURN);
}


문자열을 출력하는 함수를 선언하자
void
 lcd_str(const char * cstring)

{


  while(0!=*cstring)
    {
      lcd_data(*cstring);
      ++cstring;
    }
}


숫자를 출력하는 함수를 선언하자
void
 lcd_num(unsigned char ucnum)
{
  static unsigned char ucbuffer[] = "123";
  ucbuffer[0]='0'+(ucnum/100);        //백단위 자리수 구하기
  ucbuffer[1]='0'+((ucnum%100)/10);   //십단위 자리수 구하기
  ucbuffer[2]='0'+(((ucnum%100)%10)); //일단위 자리수 구하기
  lcd_str(ucbuffer);
}


'디지털회로' 카테고리의 다른 글

20140425  (0) 2014.04.25
20140424 USART  (0) 2014.04.24
20140421 LCD2  (0) 2014.04.21
20140417 LCD  (0) 2014.04.17
20140409 WinAVR설치  (0) 2014.04.09
by 날라차숑 2014. 4. 22. 10:27


#include <stdio.h>
#include
 "smart.h"

void inst_clear(void);    //화면클리어
void inst_return(void);   //커서제일앞으로
void inst_entry(void);    //커서이동방향 할당 및 전체디스플레이변화를 가능하게함
void inst_display(void);  //디스플레이 설정
void inst_cursor(void);   //커서무빙설정 디스플레이 방향설정
void inst_function(void); //DL:8/4bit 설정N:도트라인 설정
void data_a(void);        //데이터 집어넣는 부분
void lcd_init(void);      //설정한값을 넣는 부분

int main(void)
{

  lcd_init();
  data_a();
  data_a();
  data_a();
  data_a();
  data_a();
  

  
  while(1);
  {
  
  }        
  return 0;
}
void inst_clear(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); //DDRA방향세개를 출력으로 바꿈
  DDRC = 0xFF;                               //DDRC방향 모두를 출력으로 바꿈
  PORTA = (0<<PIN_E);

  PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC=0x01;
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void inst_return(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E);
  DDRC = 0xFF;
  PORTA = (0<<PIN_E);

  PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC=0x02;
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void inst_entry(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E);
  DDRC = 0xFF;
  PORTA = (0<<PIN_E);

  PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC=0x06;
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void inst_display(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); 
  DDRC = 0xFF;                               //DDRC방향 모두를 출력으로 바꿈
  PORTA = (0<<PIN_E);

  PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC=0xF;
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void inst_cursor(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E);
  DDRC = 0xFF;
  PORTA = (0<<PIN_E);

  PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC=0x14;
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void inst_function(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E);
  DDRC = 0xFF;
  PORTA = (0<<PIN_E);

  PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC=0x3C;
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void data_a(void)
{
  volatile unsigned int uicnt;
  DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E);
  DDRC = 0xFF;
  PORTA = (0<<PIN_E);

  PORTA=(1<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E);
  DELAY(10000);
  PORTA=PORTA|(1<<PIN_E);
  DELAY(500);
  PORTC='A';
  DELAY(10000);
  PORTA=PORTA&~(1<<PIN_E);
  DELAY(500);
  
}
void lcd_init(void)
{
  volatile unsigned int uicnt;
  DELAY(500);
  inst_function();
  inst_entry();
  inst_cursor();
  inst_display();
  inst_clear();
  inst_return();
  
}



'디지털회로' 카테고리의 다른 글

20140425  (0) 2014.04.25
20140424 USART  (0) 2014.04.24
20144022 문자열 숫자, 출력하기  (0) 2014.04.22
20140417 LCD  (0) 2014.04.17
20140409 WinAVR설치  (0) 2014.04.09
by 날라차숑 2014. 4. 21. 13:55






'디지털회로' 카테고리의 다른 글

20140425  (0) 2014.04.25
20140424 USART  (0) 2014.04.24
20144022 문자열 숫자, 출력하기  (0) 2014.04.22
20140421 LCD2  (0) 2014.04.21
20140409 WinAVR설치  (0) 2014.04.09
by 날라차숑 2014. 4. 17. 17:28

WinAVR설치

구글에서 winavr검색 다운로드하면

WinAVR20100110을 받을수 있다. 받아라 커스텀설치에서 3가지 항목나오는데 3가지 다 받아두자.

'디지털회로' 카테고리의 다른 글

20140425  (0) 2014.04.25
20140424 USART  (0) 2014.04.24
20144022 문자열 숫자, 출력하기  (0) 2014.04.22
20140421 LCD2  (0) 2014.04.21
20140417 LCD  (0) 2014.04.17
by 날라차숑 2014. 4. 9. 12:33
| 1 2 |