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 CCS Technical Support

2 PICs, I2C + 1ms Timer0 problems

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



Joined: 03 May 2007
Posts: 42

View user's profile Send private message

2 PICs, I2C + 1ms Timer0 problems
PostPosted: Wed Jun 06, 2007 4:16 pm     Reply with quote

Hello All,

The setup:
1 PIC16F677 running at 4MHz. (Slave)
1 PIC18F65J10 running at 4MHz with internal 4x PLL = 16MHz. (Master)

I2C comms are good, data does get passed with regular test code.
I2C data rate in all cases is set to "slow."


I2C comms appear to work properly between these two chips.


The issue is the following:
The 18F65J10 Master needs to keep 1ms accurately.
The 16F677 Slave doesn't really need to keep accurate time.

The 18F65J10 occasionally gets locked up----for up to 20ms, waiting for a response from the 16F677.


Questions:
#1 Are ANY of the I2C slave commands BLOCKING in this setup? Can the slave tie up the Master so that the master cannot process its instructions in the 1ms ISR ?


#2 If so, any way around this, so that the commands within the 1ms timer_isr will be processed, every 1ms?
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Jun 06, 2007 5:49 pm     Reply with quote

In I2C communications, the Slave has the ability to hold the SCL line low while it's processing whatever command you have sent to it. This tells the Master that the Slave is busy and keeps the Master from sending any more commands/data until the Slave is finished doing it's thing. If your Master code gets 'hung' during this time you might want to find out why the Slave is taking so long or make your Master code so it isn't required to wait around for the Slave to finish ho-humming around.

Ronald
davefromnj



Joined: 03 May 2007
Posts: 42

View user's profile Send private message

Hello
PostPosted: Thu Jun 07, 2007 5:28 pm     Reply with quote

rnielsen wrote:
In I2C communications, the Slave has the ability to hold the SCL line low while it's processing whatever command you have sent to it. This tells the Master that the Slave is busy and keeps the Master from sending any more commands/data until the Slave is finished doing it's thing. If your Master code gets 'hung' during this time you might want to find out why the Slave is taking so long or make your Master code so it isn't required to wait around for the Slave to finish ho-humming around.

Ronald




The master's code is structured around a taskscheduler. The taskscheduler is based on Timer0 expiring every 1ms. The problem is that apparently the compiler's i2c_read() and i2c_write() functions do not allow the Timer0_isr to interrupt the response from the slave unit.

So for whatever reason (maybe there's a good one) i2c_read() and i2c_write() have a higher priority than timer0_isr.

I'm going to try to speed up the slave's clock so that it processes the commands / sends back data faster.
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