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

Any experience with Slave I2C

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



Joined: 15 Dec 2003
Posts: 6

View user's profile Send private message

Any experience with Slave I2C
PostPosted: Wed Dec 17, 2003 3:44 am     Reply with quote

Hi everyone,

I'm seeing a I2C problem for the last couple of days.

I'm using 16f876 as master and 16f872 as slave processor. The ccs version is 3.180 and the Slave code is from Ex_slave.c

Now everything works fine on the workbench, I read analog data from the slave every 100ms. When I install it in a noisy (electrically) environmet communication stops aftre a few minutes.
The Master is still sending clock, but SDA is low, forever, Slave pulling it down.

I assum the Slave gets a spike, calls the interrupt routine and than gets no more data antill the master sends a new telegramm.

The processor is still doing the main loop, so it is not crashed.

I also can't get the I2C working again. Tried restart_cpu, SDA is low!

Any idea if it is a spike problem and how I can solve it. I don't mind if the I2C is looked for a few secunds, as long as I can detect the crash and restart it.


Slave code:

#INT_SSP
void ssp_interupt ()
{
BYTE incoming;

if (i2c_poll() == FALSE) {
if (fState == ADDRESS_READ) { //i2c_poll() returns false on the
i2c_write (buffer[address]);//interupt receiving the second
fState = NOTHING; //command byte for random read operation
}
}
else {
incoming = i2c_read();

if (fState == NOTHING){
fState = CONTROL_READ;
}
else if (fState == CONTROL_READ) {
address = incoming;
fState = ADDRESS_READ;
}
else if (fState == ADDRESS_READ) {
buffer[address] = incoming;
fState = NOTHING;
}
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 17, 2003 12:58 pm     Reply with quote

Quote:
The processor is still doing the main loop, so it is not crashed.
I also can't get the I2C working again. Tried restart_cpu, SDA is low!
Any idea if it is a spike problem and how I can solve it. I don't mind if the I2C is looked for a few secunds, as long as I can detect the crash and restart it.


On a 16F872, the reset_cpu() function jumps to rom address 0.
It doesn't do a hardware reset.

You could try some experiments. If you can detect when your problem
occurs, then you can force a WDT reset. To do this, enable the WDT in
the #fuses statement, and put restart_wdt() in the appropriate locations
in your code, so it won't normally timeout. Then, when you want to
cause a WDT reset, do this:

if(problem_occurred)
{
while(1); // Wait here until WDT causes a reset
}
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