Ivo Vach

LCD Hitachi HD44780 H9s12

Discussion created by Ivo Vach on Feb 27, 2008
Latest reply on Feb 28, 2008 by MIAN AHMED JEHANZEB ANWER NOORPURI
Hello I need connesct LCD Hitachi HD44780 to HC9S12DP256. I find this source code, but it is customized for somethig AVR. There is addres from external RAM to port A and C. I don't know i can addres from externam RAM for HC9S12dp256. Thank you many for help and i am so sorry for my english. #include "hidef.h" #include "mc9s12dp256.h" #include "lcdd.h" #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" void vInitLcd(void); void vDispIReset(void); void vClearLcd(void); void vDelay(unsigned int uiTime_us); void vPutCharToLcd( char cData, char cRs); void vDisplayBusy(void); #define LCD_8BIT 0x38 #define LCD_OFF 0x0C #define LCD_INKR 0x06 #define LCD_CLEAR 0x01 #define LCD_RS_CTRL 0 #define LCD_RS_DATA 1 #define LCD_DATA_REG (*(unsigned char*)(0xC000)) /*DATA REGISTER*/ #define LCD_CTRL_REG (*(unsigned char*)(0x8000)) /*CTRL REGISTER*/ char InfoTextL1[] = "Ondra"; char InfoTextL2[] = "ondra"; void main(void) { /* put your own code here */ unsigned char ucIndex = 0; unsigned char i = 0; EnableInterrupts; vInitLcd(); vClearLcd(); for(;:smileywink: { ucIndex = 0; do{ DisplayBusy(); vPutCharToLcd(InfoTextL1[ucIndex], LCD_RS_DATA); ++ucIndex; vDelay(65000); }while(ucIndex 20); ucIndex = 0; do{ vDislayBusy(); vPutCharToLcd(InfoTextL2[ucIndex], LCD_RS_DATA); ++ucIndex; }while(ucIndex 20); vDelay(65000); for(i=0; i10;i++){ vDelay(65000); } vClearLcd(); } /* wait forever */ /* please make sure that you never leave this function */ } void vInitLcd(void){ MCUCR |=0x80; MCUCR |=0x40; vDisplReset(); } void vDisplReset(void){ vDelay(15000); vPutCharToLcd(LCD_8BIT, LCD_RS_CTRL); vDelay(4100) ; vPutCharToLcd(LCD_8BIT, LCD_RS_CTRL); vDelay(100); vPutCharToLcd(LCD_8BIT, LCD_RS_CTRL); vDelay(100); vPutCharToLcd(LCD_8BIT, LCD_RS_CTRL); vDelay(100); vPutCharToLcd(LCD_OFF, LCD_RS_CTRL); vDelay(100); vPutCharToLcd(LCD_INKR, LCD_RS_CTRL); vDelay(100); } void vPutCharToLcd(char cData, char cRs){ if(cRs) LCD_DATA_REG = cData; else LCD_CTRL_REG = cData; } void vClearLcd(void){ vPutCharToLcd(LCD_CLEAR, LCD_RS_CTRL); vDelay(1640); } void vDelay(unsigned int uiTime_us){ uiTime_us /=17; uiTime_us *=10; while(--uiTime_us); } void vDisplayBusy(void){ unsigned char ucBusy; do{ ucBusy = LCD_CTRL_REG; }while(ucBusy & 0x80); }

Outcomes