I2C Problem

chris-s

New Member
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

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
 

chris-s

New Member
Thanks for the reply.

I can't see anything in the linked pdf, will go and have a search on the forum.

Also, I have tried it connecting to both devices 'i2cslow', same results unfortunately.

Chris
 

hippy

Ex-Staff (retired)
Staff member
That both work separately and the LCD is resetting when you read the DS1307 suggests it's the LCD driver having problems with multiple devices on the I2C bus. It may be worthwhile contacting the manufacturer to see if this is a known issue.

Do you have any other PICAXE than an 18X which suports I2C which you can use to see how it behaves using that ?
 

therowes

Member
I think your problem might be that on a multiple device I2C bus it must be run at the speed of the slowest device. The clock chip may be incorrectly sending data to the LCD causing a reset. Try with i2cslow, the correct speed for the clock chip I believe ?

Martin
 

therowes

Member
opps missed other replys sorry for repeating advice, I also had an intermittant problem with multiple devices that was fixed by reducing the pull up resistors to 2K7, the I2C bus was long about 600mm ( LCD remote ) and on a spiders web breadboard !
Martin
 

chris-s

New Member
Thanks for the replies guys.

A few more ideas to try, think I've another picaxe somewhere as well.

Cheers

Chris
 
Top