CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

communication problem with RS232 and I2C

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Jochen Kochner



Joined: 08 May 2008
Posts: 10

View user's profile Send private message Send e-mail

communication problem with RS232 and I2C
PostPosted: Thu May 08, 2008 5:08 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu May 08, 2008 8:09 am     Reply with quote

Quote:
BUT if I only use the function kbhit()

Try kbhit(RS232STR)
_________________
David
Guest








PostPosted: Fri May 16, 2008 4:14 am     Reply with quote

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







PostPosted: Fri May 16, 2008 4:41 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue May 27, 2008 4:12 am     Reply with quote

Thank's for the answer!

In the moment everything works fine! Very Happy
BUT I have decrease the BAUD_RATE of the RS232 from 19200 to 2400 and I don't know why it works! Sad

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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