i²c EEPROM to NOKIA 3310 LCD (LPH7779):

Read character en symbol data from EEPROM & send them to the NOKIA LCD.

Projects Home

 

   

This routine gets the data for one character from the EEPROM which is set by "charsel." It will then send 6 bytes "bytefornokia" to the nokia_write_data() routine.

The NOKIA LCD has 84x48 pixels. We devide this in 6 rows of 14 characters. Each character is 6 pixels wide and 8 pixels high.

When reading from the i²c EEPROM(=Slave) and seen by the PIC's point of view (=Master), we have to:

1) Send a START, write the device address (0xa0) (last bit is 0 for write), wait for ACK.

2) Write the high byte address (sets the first register to read from, which is set by "charsel" here), wait for ACK.

3) Write the low byte address (sets the first register to read from, which is set by "charsel" here), wait for ACK.

4) Send a REPEATED START, write the device address again (0xa1) (last bit is 1 for read), wait for ACK.

5) Read five bytes, wait for ACK.

6) Read the last byte, no wait for ACK, send STOP.

 

Also see the EEPROM 24C256 datasheet, and figure 8-2, Random Read.

Graphic LCD module type LPH7779 (NOKIA 3310 LCD)

And the PCD8544 datasheet.

 

 

    

Hi-Tech PICC:  

void ext_eeprom_to_nokialcd(void)

SEN = 1;                           // 1) send start bit START to EEPROM
while(SEN);
ACKDT = 0;                    // acknowledge bit

SSPIF = 0;                       // CONTROL 1
SSPBUF = 0xa0;             // set device address i2c eeprom
while(!SSPIF);                 // wait for interrupt
SSPIF = 0;

SSPBUF=((charsel>>4)&0x0f);          //
2) address ADDH to EEPROM
while(!SSPIF);                                      // wait for interrupt
SSPIF = 0;

SSPBUF=((charsel<<4)&0xf0);         //
3)address ADDL to EEPROM
while(!SSPIF);                                     // wait for interrupt
SSPIF = 0;

RSEN = 1;                     // 
4) send repeated start bit REPEATED START
while(RSEN);               // and wait for it to clear

SSPIF = 0;                           // CONTROL 2 to EEPROM
SSPBUF = 0xa1;                 // set device address  i2c eeprom
while(!SSPIF);                    // wait for interrupt
SSPIF = 0;                           // then clear it.

for (eerow=0;eerow<5;eerow++) {
5)
                                                // 5 rows read from eeprom & write to nokia ///////////
RCEN = 1;                              // start receiving READ & ACK (*5)
while(!STAT_BF);               // wait for data from EEPROM
bytefornokia=SSPBUF;       // and get it
nokia_write_data();             // send data to nokia LCD
ACKEN = 1;                         // start acknowledge sequence for EEPROM
while(ACKEN);                   // wait for ack. sequence to end
                                                        }

RCEN = 1;                             //
6) start receiving READ LAST & NO ACK
while(!STAT_BF);              // wait for data
bytefornokia = SSPBUF;    // and get it
nokia_write_data();            // send data to nokia
ACKDT = 1;                        // not acknowledge for last byte

PEN = 1;                               // send stop bit STOP
while(PEN);