BASIC4MCU | 질문게시판 | atmega128 lcd 문자열 출력 함수 오류!
페이지 정보
작성자 소리에게돈 작성일2020-10-05 22:59 조회4,867회 댓글1건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=13444
본문
// 문자열 출력 함수
void LCD_String(char flash str[])
{
char flash *pStr=0;
pStr=str;
while(*pStr) Data(*pStr++);
}
pStr=str; 여기서 계속 Error: C:\cvavreval\BIN\lcd.c(77): a value of type 'flash unsigned char []' can't be assigned to an entity of type 'flash unsigned char *' 에러가 발생합니다.아래는 원본입니다.#include <mega128.h>#include <delay.h>#define LINE2 0xC0 // 2nd Line Move#define HOME 0x02 // Cursor Home#define RSHIFT 0x1C // Display Right Shift#define LSHIFT 0x18 // Display Left Shift#define DISPON 0x0c // Display On#define DISPOFF 0x08 // Display Offvoid LCD_init(void);void LCD_String(char flash str[]);void Busy(void);void Command(unsigned char);void Data(unsigned char);void main(void){LCD_init();Command(HOME);LCD_String("Hello!!");Command(LINE2);LCD_String("Atmel ATmega128");while(1);}// LCD 초기화 함수void LCD_init(void){DDRC = 0xFF; // 포트 C 출력 설정PORTC &= 0xFB; //E = 0;// 충분한 지연시간을 통한 안정화 과정delay_ms(15);Command(0x20); // D5=1delay_ms(5);Command(0x20); // D5=1delay_us(100);Command(0x20); // D5=1// 초기화 과정Command(0x28); // function setCommand(0x06); // entry mode setCommand(0x01); // all clearCommand(0x0c); // display on}// 인스트럭션 쓰기 함수void Command(unsigned char byte){Busy();// 인스트럭션 상위 바이트PORTC = (byte & 0xF0); // 데이터PORTC &= 0xFE; // RS = 0;PORTC &= 0xFD; // RW = 0;delay_us(1);PORTC |= 0x04; // E = 1;delay_us(1);PORTC &= 0xFB; // E = 0;// 인스트럭션 하위 바이트PORTC = ((byte<<4) & 0xF0); // 데이터PORTC &= 0xFE; // RS = 0;PORTC &= 0xFD; // RW = 0;delay_us(1);PORTC |= 0x04; // E = 1;delay_us(1);PORTC &= 0xFB; // E = 0;}// 문자열 출력 함수void LCD_String(char flash str[]){char flash *pStr=0;pStr=str;while(*pStr) Data(*pStr++);}// char flash : pointer declaration for program memory// char eeprom : pointer declaration for EEPROM//데이터 쓰기 함수void Data(unsigned char byte){Busy();// 데이터 상위 바이트PORTC = (byte & 0xF0); // 데이터PORTC |= 0x01; //RS = 1;PORTC &= 0xFD; //RW = 0;delay_us(1);PORTC |= 0x04; //E = 1;delay_us(1);PORTC &= 0xFB; //E = 0;// 데이터 하위 바이트PORTC = ((byte<<4) & 0xF0); // 데이터PORTC |= 0x01; //RS = 1;PORTC &= 0xFD; //RW = 0;delay_us(1);PORTC |= 0x04; //E = 1;delay_us(1);PORTC &= 0xFB; //E = 0;}// Busy Flag Check -> 일반적인 BF를 체크하는 것이 아니라// 일정한 시간 지연을 이용한다.void Busy(void){delay_ms(2);}
댓글 1
조회수 4,867master님의 댓글
master 작성일
void LCD_String(char * s); // void LCD_String(char flash str[]);
// 문자열 출력 함수
void LCD_String(char *s){
while(*s)Data(*s++);
}
이렇게 수정해서 돌려보세요