|
|
View previous topic :: View next topic |
Author |
Message |
Jochen Kochner
Joined: 08 May 2008 Posts: 10
|
communication problem with RS232 and I2C |
Posted: Thu May 08, 2008 5:08 am |
|
|
Hello,
I have a problem with the communication between RS232 and I2C.
If I'm using only the I2C communication, everything works fine, BUT if I only use the function kbhit() => I couldn't communicate anymore about I2C!
I'm using the PIC24HJ64GP206 with the following uinterface settings:
#use rs232 (STREAM=RS232STR, BAUD=19200, UART1, PARITY=N, BITS=8, STOP=1, TIMEOUT=100)
#use i2c (master, sda=SDA, scl=SCL, SLOW=100000, FORCE_SW, STREAM=I2CSTR)
What is wrong?
Regards
Jochen |
|
|
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Thu May 08, 2008 8:09 am |
|
|
Quote: | BUT if I only use the function kbhit() |
Try kbhit(RS232STR) _________________ David |
|
|
Guest
|
|
Posted: Fri May 16, 2008 4:14 am |
|
|
Thank's for your support.
I have used this function but without success.
I think it is a timing problem because I made a very complicated (asin, acos, etc.) calculation and in this case I think the i2c bus hang-up itself.
Now I have to find this error problem!
Regards
Jochen |
|
|
Ttelmah Guest
|
|
Posted: Fri May 16, 2008 4:41 am |
|
|
On the I2C, _you_ are the master, so control the timing. Anything you do, in terms of pauses etc. in the main code, should not hang the I2C. If it does get 'hung', it probably implies an external problem like noise on the line, or that your slave is not properly handling the ACK/NACK sequencing when it replies.
Have you actually used the kbhit, _with the stream identifier_, as opposed to just calling kbhit on it's own?.
Basically, there is nothing 'wrong' in the setups as given, but there could be problems in how you then use these.
Best Wishes |
|
|
Jochen Kochner
Joined: 08 May 2008 Posts: 10
|
|
Posted: Tue May 27, 2008 4:12 am |
|
|
Thank's for the answer!
In the moment everything works fine!
BUT I have decrease the BAUD_RATE of the RS232 from 19200 to 2400 and I don't know why it works!
Do you have a idea what I can do to increase the BAUD_RATE to 19200 and to have a stable I2C bus?
Regards
Jochen |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|