void lcdInit(void) { //Port config lcd_port_dir_conf(); waitlcd(500); lcdRSOff(); lcdENOff(); lcdPortDataOut(0x03); waitlcd(40); lcdENOn(); lcdENOff(); waitlcd(5); lcdENOn(); lcdENOff(); waitlcd(5); lcdENOn(); lcdENOff(); waitlcd(2); lcdPortDataOut(0x02); lcdENOn(); lcdENOff(); lcdcmd(0x28); //set data length 4 bit 2 line waitlcd(250); lcdcmd(0x0E); // set display on cursor on blink on waitlcd(250); lcdcmd(0x01); // clear lcd waitlcd(250); lcdcmd(0x06); // cursor shift direction waitlcd(250); lcdcmd(0x80); //set ram address waitlcd(250); }
void lcdinit(void) { RS=0; EN=0; PORTC= 0x3; waitlcd(40); EN=1; EN=0; waitlcd(5); EN=1; EN=0; waitlcd(5); EN=1; EN=0; waitlcd(2); PORTC=2; EN=1; EN=0; lcdcmd(0x28); //set data length 4 bit 2 line waitlcd(250); lcdcmd(0x0E); // set display on cursor on blink on waitlcd(250); lcdcmd(0x01); // clear lcd waitlcd(250); lcdcmd(0x06); // cursor shift direction waitlcd(250); lcdcmd(0x80); //set ram address waitlcd(250); }
void lcdcmd(unsigned char Data) { RS=0; //because sending command EN=0; PORTC =((Data >> 4) & 0x0F); EN=1; waitlcd(2); EN=0; PORTC = (Data & 0x0F); EN =1; waitlcd(2); EN=0; }
void lcdData(unsigned char l) { RS=1; //because sending data EN=0; PORTC =((l >> 4) & 0x0F); EN=1; waitlcd(2); EN=0; PORTC = (l & 0x0F); EN=1; waitlcd(2); EN=0; }
void lcdData(unsigned char data) { P6OUT |= RS; // RS=1 to send data P6OUT &= ~EN; P6OUT &= 0xF0; P6OUT |= ((data >> 4) & 0x0F); // To send upper byte / 4-bits P6OUT |= EN; // EN=1 to enable waitlcd(2); P6OUT &= ~EN; P6OUT &= 0xF0; P6OUT |= (data & 0x0F); P6OUT |= EN; waitlcd(2); P6OUT &= ~EN; }
void lcdcmd(unsigned char cmd) { P6OUT &= ~RS; // RS=0 to send command P6OUT &= ~EN; // EN=0 to disable P6OUT &= 0xF0; // Keep RS, RW and EN states and reset Data P6OUT |= ((cmd >> 4) & 0x0F); // To send upper byte / 4-bits P6OUT |= EN; // En=1 to enable waitlcd(2); // delay for at least 39us // repeat to send lower byte P6OUT &= ~EN; // EN=0 to disable P6OUT &= 0xF0; // Keep RS, RW and EN states and reset Data P6OUT |= (cmd & 0x0F); // To send lower byte / 4-bits P6OUT |= EN; // EN=1 to enable waitlcd(2); // delay for at least 39us P6OUT &= ~EN; // EN=0 to disable }
void lcdinit(void) { P6OUT &= ~RS; // RS=0 to send cmd P6OUT &= ~EN; // EN=0 to disable P6OUT |= 0x3; // Wakeup (0x30) waitlcd(40); // wait for 30ms // 4-bits initialisation sequences P6OUT |=EN; // enable P6OUT &=~EN; // disable waitlcd(5); // P6OUT |=EN; // enable P6OUT &=~EN; // disable waitlcd(5); // P6OUT |=EN; // enable P6OUT &=~EN; // disable waitlcd(2); // P6OUT &= 0xF2; // clear (0x02) - Return Home (see page 18) P6OUT |=EN; P6OUT &=~EN; lcdcmd(0x28); // set data length 4 bit 2 line 5x8 dot (see page 19/20) waitlcd(250); lcdcmd(0x0F); // set Display On; Cursor On; Blink On (see page 19) waitlcd(250); lcdcmd(0x01); // Clear display (see page 18) waitlcd(250); lcdcmd(0x06); // Entry mode set - cursor shift direction to right (see page 18) waitlcd(250); lcdcmd(0x80); //set DDRAM address (see page 20) waitlcd(250); }