View previous topic :: View next topic |
Author |
Message |
Nightmaretony
Joined: 14 Apr 2006 Posts: 5 Location: Nightmare Park, CA
|
Posted: Sat Apr 15, 2006 12:06 am Post subject: I2C and curious festivities |
|
|
Am doing a work project of a test fixture,. It uses several boards, each with an AT89C2051 talking via an I2C bus. One master to control them all, each module may send back status if polled.
Finally got the buggers to want to talk. Test circuit is one board simply sending out decimal 50 once a second. Next board receives it and puots it through the RS232 port. Already figured out the gotcha of using 2400 baud and that the Put#1 command in the book simply doesnt work.
the problem I am having is that I am getting data from the yelling board, it gives me a random return of &HF0, &HE0 or &HC0. I am sending out a decimal 50, was using a decimal 49 and 50 with no effect.
important code loop below for each board...
(this is the board that sends out the bytes once a second...
Main:
Do
Greenled1 = On
Value = 50
Call I2send
Wait 1
Greenled1 = Off
Value = 50
Call I2send
Wait 1
Loop
End
Sub I2send(slave As Byte , Value As Byte)
' I2csend Slave , Value"
I2cstart
I2cwbyte Slave
I2cwbyte Value
I2cstop
End Sub
Sub I2receive(master As Byte , Value As Byte)
' I2creceive Master , Value
I2cstart
I2cwbyte Master
I2crbyte Value , Nack
I2cstop
End Sub
The other board code is as follows (the subroutines of the i2send and i2c are t5he same, so they are ommitted for clarity)
Master = Testboard
Slave = Solboard
'The main loop
Main:
Do
Value = 0
Call I2receive
If Value = 0 Then Goto Main
If Value = 255 Then Goto Main
Print "The value is: " ; Value ' out rs232
Waitms 10
Loop
End
the RS232 part works out fine, it is just the I2C code coming back as garbage.
(in the i2send and recieve, I have the full command commented out to use that instead of the individual rw/s, same kind of problem still exists)
somewhere, it may have been mentioned about 2051s as slave3s, there might be a gotcha I am not aware of that I cannot find solid documentation about.
Help! _________________ For this is the place
where dreams
and nightmares
are birthed
and bred
Nightmare Park |
|
Back to top |
|
|
mtheriault2000
Joined: 12 Oct 2005 Posts: 9
|
Posted: Sun Apr 16, 2006 3:33 am Post subject: |
|
|
Hello.
How long is the I2C cable between your test fixturs boards? The original I2C protocol has been establish for communication between ic's on the same board.
Maybe the solution will be to use an 82B715 or 82B96, I2C buffer line from Phillips. These chip will allow you to transmit of to 30 meters. If you use it, don't forget to calculate and install the pull-up resistance (look in the litterature). You couls also increase the I2C delay by software.
I had the same problem, and using the 82B715 resolved it.
Good luck
Martin. |
|
Back to top |
|
|
Nightmaretony
Joined: 14 Apr 2006 Posts: 5 Location: Nightmare Park, CA
|
Posted: Tue Apr 18, 2006 12:04 am Post subject: |
|
|
The cable is 4 inches long.
I have more given up on this as it appears that the AT89C2051 cannot act like an I2C slave. Cant find any code and it was mentioned somewhere in my travels online, wish I remeber where.
The specialized aplication is using about 5 or 6 2051s in a chain with aq single master, except that one of the slaves can turn into a master to send back information.
am going to a 65C134. 6502 based, 4k library built in, external ram and rom capable and 28 port pins. single board, no I2C.
thanks though. am going to use the 2051 for other things such as RC5 decoding to send out, but for I2C i consider it a dead issue for this project. _________________ For this is the place
where dreams
and nightmares
are birthed
and bred
Nightmare Park |
|
Back to top |
|
|
Vilko
Joined: 25 May 2004 Posts: 190 Location: Ljubljana, Slovenia
|
Posted: Tue May 02, 2006 7:54 pm Post subject: Hi |
|
|
Well, when i wanted to share information among few 2051 or 8252 and it was no possible use serial port, i used a i2c eeprom slave for all 2051 masters. When first 2051 wanted to tell something to the second 2051, he simply wrote it on eeprom on specific address, the second (third ) 2051 periodically read the eeprom, if there is some message to read.
Well i also used a third wire to signal i2cbus free. It was simply a one portpin of each 2051 wired together with one pullup resistor. Before a 2051 seases the i2c bus, tests the i2cfree alias portpin for high. If high, puts it down and writes or read on the bus.
It is not fast, but i didnt need to be speedy. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|