3.d.03. Command 248: Read from EEPROM
Effect: This command will read a byte from the specified address of the mega168’s EEPROM and return it to the mega644 using the SPDR. The EEPROM is addressed by a 9-bit value (512 bytes of memory). When processing the command byte, the SPI interrupt routine will check to see if it’s currently possible to read from the EEPROM. It will load the value of the EECR’s EEPE bit (programming enable bit of the EEPROM control register) into bit zero of SPDR. It is recommended you do not begin transmission of the data byte until 3 us after the transmission of the command byte has completed. This is to make sure the mega168 has time to load the SPDR. If SPDR is zero after transmission of this data byte, it is possible to perform the read, otherwise the read will not be allowed (the only time a read is not allowed while a write is in progress) . After the transmission of the data byte completes, it is recommended you wait another 3 us and then send a junk data byte or the NULL command. Upon completion of this transmission SPDR will contain the byte stored at the specified EEPROM address, assuming the read was allowed.
This command should be used to obtain the current mega168 settings if you need to figure out what they are.
Values sent: EEPROM address (9 bits)
command byte = 248 | (bit 7 of read address << 1) | bit 8 of read address
data byte = seven lowest bits of read address (bits 6 – 0)