Hello, I am having problem interfacing HD77480 controller based 16x2 LCD to LCP1769 mcu in 4 bit mode. The black line never disappears. I also tried adding pull-up resisors, however that doesn't solve the problem. I ported code which I wrote for AVR, it was working just fine with it. Maybe there are problems with delays? I also attached LED's on data lines and I see that data is being sent, however screen doesn't show anything.
#include <cr_section_macros.h> #include <NXP/crp.h> __CRP const unsigned int CRP_WORD = CRP_NO_CRP; #include "lpc17xx.h" #include "type.h" #define RS 0 #define EN 2 void init(void); void writeCmd(unsigned char a); void writedat(unsigned char b); void sendstring(unsigned char *c); void delay(int count); void high_to_low_pulse(void); void setdata(unsigned int data); unsigned char i,j; unsigned char vardas[] = "Andrius"; void init() { writeCmd(0x02); writeCmd(0x28);//4 bit mode, 2 display lines writeCmd(0x0C); writeCmd(0x06); } void writeCmd(unsigned char a) { LPC_GPIO2->FIOCLR = (1 << RS); setdata(a);//(a >> 4); high_to_low_pulse(); setdata(a<<4);//(a & 0x0F); high_to_low_pulse(); } void writedat(unsigned char b) { LPC_GPIO2->FIOSET = (1 << RS); setdata(b);//(b >> 4); high_to_low_pulse(); setdata(b<<4);//(b & 0x0F); high_to_low_pulse(); } void sendstring(unsigned char *c) { while(*c) writedat(*c++); } void delay(int count) { int j=0, i=0; for (j=0;j<count;j++) for (i=0;i<900;i++); } void high_to_low_pulse(void) { LPC_GPIO2->FIOSETL = (1 << EN); delay(10); LPC_GPIO2->FIOCLRL = (1 << EN); } void setdata(unsigned int data) { if (data & (1<<0)) LPC_GPIO2->FIOSET0 = (1<<3); else LPC_GPIO2->FIOCLR0 = (1<<3); if (data & (1<<1)) LPC_GPIO2->FIOSET0 = (1<<4); else LPC_GPIO2->FIOCLR0 = (1<<4); if (data & (1<<2)) LPC_GPIO2->FIOSET0 = (1<<5); else LPC_GPIO2->FIOCLR0 = (1<<5); if (data & (1<<3)) LPC_GPIO2->FIOSETL = (1<<6); else LPC_GPIO2->FIOCLRL = (1<<6); } int main(void) { LPC_PINCON->PINSEL2 &= ~(0xFFFFFFFF); //LPC_PINCON->PINSEL2 |= (1 << 3)|(1 << 4)|(1 << 5)|(1 << 6); LPC_GPIO2->FIODIR |=(1 << RS)|(1 << EN)|(1 << 3)|(1 << 4)|(1 << 5)|(1 << 6); init(); writeCmd(0x80); sendstring(vardas); while(1); return 0; }
Yes, it's HD44780, sorry, I guess I was thinking about something else when I wrote HD77480. Well, I checked several times if pins are right but maybe I was wrong and I can't see that. Well, first thing is to check delays.