Hi folks,
Working on my first project involving TWO i2c devices. One is the DS1307 clock and the other is an LCD display driver chip from ByVac.
Both individually work fine, but when I try to use both, the display appears to keep being 'reset'. I can tell it gets reset since it displays a 'start up' message.
I'm using a picaxe 18x firmware version 6.
Before you ask, I only have one set of pull-up resistors on the bus and both the i2c devices have different addresses.
The ds1307 bits are on a small pcb, the rest is all on a breadboard. I've re-wired it again, again and again just to make sure it's correct and that I've eliminated any dodgy connections but the problem keeps occuring.
The circuit includes the minimum components and connections to interface the picaxe and the two i2c devices.
I've cut the code right down, and included it below, where I've identified the point at which the display appears to get reset. The fault with the display occurs when I READ the DS1307 which I really can't fathom?
I've played around with delays all over the place, thinking I might need to allow more time for the i2c commands to complete, but it makes no difference, the moment I read the ds1307, the display chip resets itself. The clock reads correctly thru out.
Any pointers would be greatly appreciated
Working on my first project involving TWO i2c devices. One is the DS1307 clock and the other is an LCD display driver chip from ByVac.
Both individually work fine, but when I try to use both, the display appears to keep being 'reset'. I can tell it gets reset since it displays a 'start up' message.
I'm using a picaxe 18x firmware version 6.
Before you ask, I only have one set of pull-up resistors on the bus and both the i2c devices have different addresses.
The ds1307 bits are on a small pcb, the rest is all on a breadboard. I've re-wired it again, again and again just to make sure it's correct and that I've eliminated any dodgy connections but the problem keeps occuring.
The circuit includes the minimum components and connections to interface the picaxe and the two i2c devices.
I've cut the code right down, and included it below, where I've identified the point at which the display appears to get reset. The fault with the display occurs when I READ the DS1307 which I really can't fathom?
I've played around with delays all over the place, thinking I might need to allow more time for the i2c commands to complete, but it makes no difference, the moment I read the ds1307, the display chip resets itself. The clock reads correctly thru out.
Any pointers would be greatly appreciated
Code:
symbol VERSION = 2
symbol SECONDS = b0
symbol MINUTES = b1
symbol HOURS = b2
symbol SAVED_SECONDS = b6
pause 500
'**** Setup the display ****
i2cslave $42,i2cfast,i2cbyte 'configure i2c for the display
pause 500
writei2c 1,($0D) 'clear display, cursor off
pause 10
writei2c 3,(0) ' back light on
pause 10
CLOCK_LOOP:
i2cslave $D0, i2cslow, i2cbyte ‘ configure i2c to read ds1307 clock
CLOCK_LOOP2:
pause 100
readi2c 0, (SECONDS, MINUTES, HOURS) 'this read causes the display to reset??
pause 50
if SECONDS = SAVED_SECONDS then goto CLOCK_LOOP2
pause 50
i2cslave $42,i2cfast,i2cbyte ' switch i2c to display
pause 100
writei2c 1,($80) ' position cursor
pause 100
bcdtoascii HOURS, b4,b5
writei2c 2,("Time:",b4,b5,":")
sertxd ("Time:",b4,b5,":")
pause 50
bcdtoascii MINUTES, b4,b5
writei2c 2,(b4,b5,":")
sertxd (b4,b5,":")
pause 50
bcdtoascii SECONDS, b4,b5
writei2c 2,(b4,b5)
sertxd (b4,b5,13,10)
pause 100
SAVED_SECONDS = SECONDS
goto CLOCK_LOOP