PDA

View Full Version : I2C not working on P8



ShawnMack
01-07-2006, 05:59 PM
I'm stumped but I'm also fairly new at this so I shouldn't be surprised. I’ve hooked up the external EPROM (24LC32A) that came with my kit. I copied the code with LCD and Eprom interface routines in it and fired it up. The LCD displays the data it’s supposed to but the only data that comes back from the Eprom is 255.
·
Not easily deterred I double checked all my jumpers, heeding the warning about pulling up the SDA and SCL, still nothing.
·
I radically shortened the code to write a single known value (83) to address 0 and then retrieve it, still value 255.
·
Eventually I removed my LCD and rewired the I2C to P0 & P1 instead of P8 and P9 viola it works perfectly. Any idea why this would happen? Is there something I needed to do to force 8&9 to be I2C?
·
I’ve tried writing data with 0&1 and reading it with 8&9 and got 255. Interestingly I wrote data with 8&9 then tried reading it with 0&1 and got my test values!
·
Any help or direction would be greatly appreciated, as I’d really like to get my LCD back.

Forrest
01-07-2006, 09:50 PM
How about posting your code and a schematic so we can help you.

ShawnMack
01-08-2006, 05:08 AM
Sample code


' {$STAMP BS2p}
' {$PBASIC 2.5}
' {$PORT COM1}
' ================================================== =======================
' -----[ Program Description ]---------------------------------------------
'
' Writes to and reads from I2C EEPROM. Data is displayed in debug.
'
' -----[ I/O Definitions ]-------------------------------------------------
'
I2Cpin PIN 0 ' SDA on 8; SCL on 9
'
' -----[ Constants ]-------------------------------------------------------
'
MaxEE CON 4095 ' highest EE address
'
' -----[ Variables ]-------------------------------------------------------
'
addr VAR Word ' EE address
addrHi VAR addr.HIGHBYTE
addrLo VAR addr.LOWBYTE
tOut VAR Byte ' test value to LCD
tIn VAR Byte ' test value read from LCD
' -----[ Main Code ]-------------------------------------------------------
'
Splash:
DEBUG "Eprom R/W testing"
Main:
DEBUG "Loading"
GOTO ReaditOnly
tOut = 83
addr = 0
' write value
I2COUT I2Cpin, $A0, addrHi\addrLo, [tOut]
PAUSE 250
tOut = 83
addr = 10
' write value
I2COUT I2Cpin, $A0, addrHi\addrLo, [tOut]
PAUSE 250
ReaditOnly:
addr = 0
'Get Value
I2CIN I2Cpin, $A1, addrHi\addrLo, [tIn]
' display results
DEBUG CR, "0=",DEC tIn
PAUSE 250
addr = 10
'Get Value
I2CIN I2Cpin, $A1, addrHi\addrLo, [tIn]
' display results
DEBUG " 10=",DEC tin
PAUSE 250
END


Yes I am very careful to change the I2CPin from 0 to 8 as·it is changed on the board.

The red wires on the attached picture are the wires the project paper describe. These two are not wired att the same time as P0 and P1 but instead of.

Well I hope there is an attachment...

Jon Williams
01-08-2006, 05:18 AM
The structure of the socket connections on the BS2p24/40 demo board cause the BS2p24 P8-P15 connections to be connected to the A8-A15 sockets.· This is noted on pages 2 and 12 of the demo board documentation:

http://www.parallax.com/dl/docs/prod/boards/BS2p2440DBrd.pdf

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

ShawnMack
01-08-2006, 05:23 AM
Argh, I was bit by RTFM,·last line on the last page past all the samples http://forums.parallax.com/images/smilies/shocked.gif

"Also note that when using a 24-pin module, pins P8 through P15 are accessed via sockets A8 through A15."

I'll bet most everyone else knows this by second nature. Thanks anyone that took the time to look at this.

Jon Williams
01-08-2006, 05:24 AM
Yes, one should always Read The Fabulous Manual....

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

ShawnMack
01-08-2006, 05:29 AM
Too slow to find my own mistake, Jon beat me to it. You were, of course, dead on.

Humm, it is on page 2. Now I do feel bad.·And a quick vow to never be snide to someone asking a question answered on page 2 of the Freakin' Manual.