AN #132 - Interfacing an external I2C EEPROM for the T6963C Graphical Display



This AN was written by Jan Petersen.

BASCOM can store RLE encoded pictures into the AVR internal EEPROM. This space is very limited and this AN shows how to use an external EEPROM so you can store more pictures.

In order to get this functionality you need to change the graphics library file.

open glcd.lib with notepad
Find [_GetByteFromROM_EPROM]
Cut / past with this:

[_GetByteFromROM_EPROM]
$EXTERNAL _READEEPROM , _LPMBYTE, _i2c_read, _i2c
; get a byte from code ROM or from EEPROM
;you could write code to get the data from an external EEPROM
_GetByteFromROM:
Tst R23 ; is it 0 ?
Breq _GetByteFromROM1 ; yes get from flash

Clr R26 ; point to R0
Clr R27

*BASIC: I2Cstart ;generate I2C start
*BASIC: I2Cwbyte eeprom_address ;Access EEPROM by writing Base adrress (Const declared in main basic prg.)

mov R17, ZH ;Move adress pointer to R17 (used in _i2c_write)
call _i2c_write ;Write High address to EEPROM
mov R17, ZL
call _i2c_write ;Write High address to EEPROM

*BASIC: I2Cstart ;generate I2C start
*BASIC: Const eeprom_read = eeprom_address+1
;Incr address by one (=Read)
*BASIC: I2Cwbyte eeprom_read ;Set EEPROM in Read mode

Sec ;Set Carry bit for last byte read
call _i2c_read ;Read, result i R17
mov R0, R17 ;move R17 to R0
*BASIC: I2Cstop ;generate I2C stop

Adiw R30,1 ;Inc address pointer
ret ;Return

_GetByteFromROM1:
jmp _LpmByte ;returns data in r0
[END]
Save and Compile the library with the LIB manager

As an alternative, you can copy the glcd.lib to a new library and modify that one. Then you can refer to this new lib with $LIB "mynewglcd.lbx"

Download source code and files in an132.zip