Free Code: I2C with AXE033

bruciferofbrm

New Member
Here is some code I wrote for my AXE-033 LCD with clock chip in I2C mode.
Note: this runs on an X and X1 based chip (I used a 28X1, but I am only using its I2C bus for this - no input or output requirements for this beyond those)

Code:
'clock program for LCD in I2C mode
' B Sherwood - 10/26/2008 - free to share

'let LCD/everything warm up
init:
pause 500

'clear LCD
i2cslave $C6,i2cslow,i2cbyte 'set up i2cslave
writei2c 0,(254,1,255)
pause 30

main:
'get current time
i2cslave %11010000, i2cslow, i2cbyte 'set slave details

readi2c 0, (b0, b1, b2, b3, b4, b5,b6,b7) 'read sec, min, hour,DoW,day,month,year

'display current time
i2cslave $C6,i2cslow,i2cbyte 'set up i2cslave

' store time into memory - converting and building a string as we go
'convert hours to ascii
bcdtoascii b2,b8,b9
poke 80,b8
poke 81,b9

'write a semi colon
poke 82,58

'convert minutes
bcdtoascii b1,b8,b9
poke 83,b8
poke 84,b9

'write a semi colon
poke 85,58

'convert seconds
bcdtoascii b0,b8,b9
poke 86,b8
poke 87,b9


'convert month
bcdtoascii b5,b8,b9
poke 88,b8
poke 89,b9

'write a slash
poke 90,47

'convert day
bcdtoascii b4,b8,b9
poke 91,b8
poke 92,b9

'write a slash
poke 93,47

'convert year
bcdtoascii b6,b8,b9
poke 94,b8
poke 95,b9

gosub lcdwrite

goto main


lcdwrite:

writei2c 0,(254,132,255) ' move to start
pause 10 ‘ wait for LCD

'read in from memory and write out to LCD display
for b1 = 80 to 87
 peek b1,b2
writei2c 0,(b2,255)
pause 10
next

'next line - date in US english format (Month / Day / Year )
writei2c 0,(254,196,255)
pause 10

for b1 = 88 to 95
 peek b1,b2
writei2c 0,(b2,255)
 pause 10
next

return
 
Last edited:

westaust55

Moderator
Hi, and as a relatively new contributor (albeit a member for some time) welcome to the forum,

You have done well in your initial launch into i2c comms.

Recognising that you are new to the forum, so for your future reference, can I suggest that:
1. you read the thread: Read Me First! http://www.picaxeforum.co.uk/showthread.php?t=7679
Which seeks that all code (other then a few lines) be enclosed in code markers so it shows up in a sub window.
2. where you are posting some working code for future use by others that you put it in the “Code Snippets” folder http://www.picaxeforum.co.uk/forumdisplay.php?f=39
 
Top