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

I2C Master & Slave with 2 PIC's SOLVED
Goto page Previous  1, 2, 3, 4, 5, 6
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19477

View user's profile Send private message

PostPosted: Tue Feb 04, 2020 1:42 am     Reply with quote

Good. Very Happy

It's actually potentially 'interesting'. In the PIC, interrupts are only responded
to in the first sub state of the instruction. So anything that results in
an instruction 'not terminating' can prevent interrupt handling.

Now have found references that MicroChip have two different internal
state machines used to handle the I2C master. On one if the slave
holds SCL, the master state machine actually stops inside the transmitting
instruction. When I found this, what had to be happening became 'clear'.
Sad
Not good, really a fault with how the I2C hardware is implemented on the
PIC.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

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

PostPosted: Tue Feb 04, 2020 3:09 am     Reply with quote

Hi Ttelmah

You wrote:
Quote:
... if the slave
holds SCL, the master state machine actually stops inside the transmitting
instruction.

It means that if it happens, a safety procedure like WDT or a timer counting for time and interrupts will not work?
It mean that is not safe to use I2C on PIC?
Maybe have to make a safety procedure in the Slave?
I am resetting the WDT just in main and DWT is set to 16ms also in the Master and in the Slave.

If the WDT was resetting, I was getting errors. As I understand from what you wrote, this what happened when the I2C was Slow=50000.
I understand correct?

Best wishes
Joe
Ttelmah



Joined: 11 Mar 2010
Posts: 19477

View user's profile Send private message

PostPosted: Tue Feb 04, 2020 4:20 am     Reply with quote

The watchdog _will_reset the machine (it is independant of the processor
itself), but the timer counter will not (since the processor is effectively
stopped 'inside' an instruction).
It also won't happen if you can use DMA for this transfer (since then it
is the DMA controller, not the processor kernel itself that is performing
the operation.
However, just use software. For a master, at reasonable clock rates,
software I2C is as fast, and has far fewer issues. One of these things
where the MicroChip hardware is not actually that well designed....
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

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

PostPosted: Tue Feb 04, 2020 7:22 pm     Reply with quote

Thank you Ttelmah

I remain with the WDT enabled at 16ms in the Master and the Slave.

Best wishes
Joe
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6
Page 6 of 6

 
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