Advertisement  

Thursday, 02 May 2024
     
 
Main Menu
Home Home
Shop Shop
News News
BASCOM-AVR BASCOM-AVR
BASCOM-8051 BASCOM-8051
Products Products
Application Notes Application Notes
Publications Publications
Links Links
Support Center Support Center
Downloads Downloads
Forum Forum
Resellers Resellers
Contact Us Contact Us
Updates Updates
MCS Wiki MCS Wiki
Online Help
BASCOM-AVR Help BASCOM-AVR Help
BASCOM-8051 Help BASCOM-8051 Help
Contents in Cart
Show Cart
Your Cart is currently empty.
Search the Shop

Products Search

User Login
Username

Password

If you have problem after log in with disappeared login data, please press F5 in your browser

RSS News
 
     
 

 
   
     
 
AN #132 - Interfacing an external I2C EEPROM for the T6963C Graphical Display Print
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.


'******************************************************************************
' (c) Jan Petersen
' Orevej 6
' DK 4760 Vordingborg
' jan_p@post8.tele.dk
'
'------------------------------------------------------------------------------
' Author : Jan Petersen
' Filename : Glcd-sample.bas
' Title : Interfacing external I2C EEPROM for T6963 Graphic display
'
' Compiler : Bascom AVR 1.11.7.4
' Library : Mcs
' IDE : Bascom
'
' Note :
'
' Date : 16.01.2004
' Current Ver. : 0.1.0
' History
'
' 0.1.0 :
'
' Need to be
' Fixed / Added :
'
' Description :
'******************************************************************************

'>>> Compiler statement
$regfile = "8515def.dat"
$crystal = 7372800

$eeprom 'Store following data in external EEP file
0
:
$bgf "C:\AVR\Graphic-LCD\00.bgf" 'You graphic files here
1
:
$bgf "C:\AVR\Graphic-LCD\01.bgf" 'Compile you bitmap file with
2
: 'the Graphic Converter found in Tool
$bgf "C:\AVR\Graphic-LCD\02.bgf"
3
: 'Remember to uncheck Uncompressed
$bgf "C:\AVR\Graphic-LCD\03.bgf" 'so the files are coded in RLE
4
:
$bgf "C:\AVR\Graphic-LCD\04.bgf" 'In this example use folowing settings:
5
: 'Width=16
$bgf "C:\AVR\Graphic-LCD\05.bgf" 'Hight=16
6
: 'LCD-Type=240x64
$bgf "C:\AVR\Graphic-LCD\06.bgf" 'or change Config Graphlcd
7
: 'and all Showpice
$bgf "C:\AVR\Graphic-LCD\07.bgf"
8
: 'Program you EEPROM
$bgf "C:\AVR\Graphic-LCD\08.bgf" 'with you preferred tool.
9
: 'or visit http://www.LancOS.com
$bgf "C:\AVR\Graphic-LCD\09.bgf" 'for free programmer and simple hardware guide
dot
:
$bgf "C:\AVR\Graphic-LCD\dot.bgf"
$data

I2CINIT 'initializ routine for I2C
 
'needed for proper function of Glcd.lib


'>>> VARIABLE Declaration <<<<<<<<<<<<<<<<<<<<<<<<
Const eeprom_address = 162 'Defines the adrress of the external EEPROM
 
'This is used in the library, don't change the name
  
'The adrress 162 is used on
 
'a Atmel 24LC64 with A0 @ 1 , A1 @ 0 , A2 @ 0

'>>> PORT Declaration <<<<<<<<<<<<<<<<<<<<<<<<<<<<
Config Scl = Portc.1  'Define you EEPROM port pin here
Config Sda = Portc.2

Config PortC = &B11111000 'config port direction (0=input)

'Config you display as needed
Config Graphlcd = 240 * 64 , Dataport = Porta , Controlport = Portb , Ce = 1 , Cd = 2 , Wr = 3 , Rd = 4 , Reset = 0 , Fs = 5 , Mode = 8


'--- Program START
gosub _lcd_intro_1 'show some text

Cls 'clear screen
Showpice 0 , 16 , 0  'show first picture named (0)
Showpice 16 , 16 , 1 'show second picture named (1)
Showpice 32 , 16 , 2
Showpice 48 , 16 , 3
Showpice 64 , 16 , 4
Showpice 80 , 16 , 5
Showpice 96 , 16 , 6
Showpice 112 , 16 , 7
Showpice 128 , 16 , 8
Showpice 144 , 16 , 9
Showpice 160 , 16 , dot 'show picture named (dot)


do
 
'endless loop
loop


_lcd_intro_1
:
' Show some text on LCD
'************************************************
 
Cls
 
Cursor Off
 
Locate 1 , 1 : Lcd "Hello"
 
Locate 2 , 1 : Lcd "Lets try to show some graphic"
 
Locate 3 , 1 : Lcd "stored in external I2C EEPROM"
 
Locate 4 , 1 : lcd "Part of Glcd.lib rewritten by"
 
Locate 5 , 1 : Lcd "Jan Petersen 2004"
 
wait 4
return

end

 

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 ;Acces 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