I have a I2C module consisting of a DS1307 rtc and an AT24C32 eeprom.
Using the usual hi2cout 0,(ABCDE) and reading back gives correct results
This code is an effort check address increments with event calls.
Time and date display ok, I never had an issue with this, but the count (incr) and the Add (address)
do not follow what I expected (wanted!)
The LCD shows the count incrementing on the *0 and *5 minutes, but the address doesn't follow, often sticking at 2.
Any ideas would be appreciated
Using the usual hi2cout 0,(ABCDE) and reading back gives correct results
This code is an effort check address increments with event calls.
Code:
'working 30/11
#picaxe08M2
#No_Data
symbol LCD= c.0
symbol DEG= c.4
symbol incr=w13
symbol flag=b24
symbol address=w11
let w11=1
high c.0
serout LCD,N2400,(254,1,254,1) 'clear screen
pause 200
hi2csetup i2cmaster, %10100000, i2cslow, i2cword
hi2cout 0,(w11) ' Write initial address to location 0
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'The main loop
Main:
debug
gosub timeit
gosub disp1
pause 5000
goto main
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Get RTC data then ....
timeit:
hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte
hi2cin 0,(b0,b1,b2,b3,b4,b5,b6)
pause 50
b11=b2/16 'hour MSD
b12=b2 & $0F 'hour LSD
b7=b1/16 'min MSD
b8=b1 & $0F 'min LSD
b9=b4/16 'day MSD
b10=b4 & $0F 'day LSD
b2=b5/16
b3=b5 & $0F
b0=b6/16:b4=b6 & $0F
'''''''''''''''''''''''''''''''''''''''''''''''''''''
' ..... check event parameters
If b8 = 0 or b8 = 5 Then
If flag = 0 Then gosub count_it
flag = 1
'End If
Else
flag = 0
End If
return
''''''''''''''''''''''''''''''''''''''''''''''''''''
'This displays HH:MM and DD/MM/YY on line 1
disp1:
serout LCD,N2400,(254,128,#b11,#b12,":",#b7,#b8," ") 'H/M
serout LCD,N2400,(254,136,#b9,#b10,"/",#b2,#b3,"/",#b0,#b4)
return
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This bit writes info to AT24C32 EEPROM
'Entry conditions are:- b8=0 or b8=5 and Flag set to zero
'address=w11
'incr=w13
'flag=b24
count_it:
let flag=1 'stop further event
hi2csetup i2cmaster, %10100000, i2cfast, i2cword 'set up eeprom
hi2cin 0,(address) 'get next address from location zero
let incr=incr+1 'increment event counter
hi2cout address,(incr) 'store counter in next eeprom location
address=address+1 'increment eeprom address
hi2cout 0, (address) 'and write it to location zero
gosub disp2 'show counter and current address
return
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This bit displays event count and next address on line 2
disp2:
serout LCD,N2400,(254,192,"Count ",#incr," Add ",#address)
pause 100
return
do not follow what I expected (wanted!)
The LCD shows the count incrementing on the *0 and *5 minutes, but the address doesn't follow, often sticking at 2.
Any ideas would be appreciated