??? 08/05/04 20:15 Read: times |
#75503 - Erik, Russell, Kai...LCD Code... Responding to: ???'s previous message |
Quick notes:
-Kai: Nice idea, modified LCD ex. prog. to my CPU, no repsonse at LCD -Erik: the circuit is o.k., as it works (LCD responds) with assembly program...(A51) never from my C versions... -Russell: Thanks for advice..my specs (as first posted) are: Atmel/Temic 80c51, 12 cycle @ 11.059 MHz, external EEPROM for code on P0 & P2. 8051 board I have uses a bootloader (2nd PROM) to write the code to an EEPROM via DOS/serial port from .HEX file. Please note that I've everone's suggestions...maybe start back again as sugg. by Russell...maybe data sheet is not accurate(?). Would anyone please mind reviewing this short init. attempt code? /************************************* | "LCDtest6.c" | LCD command/data transmittal | program for ATMEL (Temic)T80C51 | microcontroller ====================================== | Tests initialization of a 2x16 | LCD 44780-based display module, 8 bit | dat/cont. sent, 2 control bits: | RS = control/data = 0/1 = P3.2 | E = enable = P3.4 | R/W* = P3.3 | P1 = output | (P3 = output) | IE = interrupts disabled |-------------------------------------- | 8/4/04 Marty McLeod | IDE: Keil uVision2 Eval V7 ---------------------------------------*/ #include <reg5101.h> unsigned int i; unsigned int j; //Function prototypes here void DELAY(void); void NOP(void); //Begin main of program void main(void) { //Initialize 8051 SFRs: IE = 0; //Disable interrupts P1 = 0x00; //Set port 1 to OUTPUT P3 = 0x00; //Set port 3, all bits, to OUTPUT // PSW = 0x00; //Clear program status word PS while(1) { /********************************************/ //Attempt to do partial initialization: DELAY(); DELAY(); //Command: for 8 bit, 2 lines P3_2 = 0; //RS = control P3_4 = 1; //E = true then post command, then wait... P1 = 0x38; //8 bit, 2 lines DELAY(); //wait P3_4 = 0; //Toggle E low // DELAY(); DELAY(); //Command: clear P3_2 = 0; //RS = control P3_4 = 1; //E = true then post command, then wait... P1 = 0x01; //Display on, cursor off DELAY(); //wait P3_4 = 0; //Toggle E low // DELAY(); DELAY(); //Command: on P3_2 = 0; //RS = control P3_4 = 1; //E = true then post command, then wait... P1 = 0x0C; //Display on, cursor off DELAY(); //wait P3_4 = 0; //Toggle E low }//while(1) end }//main(void) /****************************/ /* Functions defined below */ void DELAY(void) { for(i = 0; i < 3000; ++i) { NOP(); } } void NOP(void) { j = 0; } /**** END OF FILE ****/ |