Microchip MSSP Module: Does a Write Collision (WCOL) Set Interrupt Flag?

Thread Starter

jpanhalt

Joined Jan 18, 2008
11,087
I am reviewing and editing some working I2C code from January, 2016. In my notes, I wrote that a write collision per se does not set an interrupt flag. That is, it can only be detected by testing the SSPxCON1 register. Unfortunately, I neglected to reference my comment. Elsewhere, I see "hints" that it is one of the events that can set the SSPxIF.

upload_2016-4-28_12-39-7.png

If it sets that flag, then one wouldn't need to test SSPxCON1, WCOL (as I currently do) and could rely on the interrupt flag.

I have been using the code for 3 months to communicate periodically with the EEPROM on a DS3231 RTC module and have yet to see any failures. My set-up is a single master (16F1829) and single slave (DS3231) at 100 kHz with LED's that are set with any BCL, WCOL, or ACK failure. Language is Assembly.

Regards, John
 

Papabravo

Joined Feb 24, 2006
21,159
For every flag that triggers an interrupt there should be a corresponding interrupt enable bit. If the interrupt enable bit for the flag is not set then you don't have to check the bit in an ISR (Interrupt Service Routine). If you don't have individual enable bits for conditions that set an interrupt flag then you need to eliminate it as a possible interrupt source in the ISR. IIRC it is actually pretty hard to create a WCOL in a single master system. In a multi-master system this might not be true.
 

Thread Starter

jpanhalt

Joined Jan 18, 2008
11,087
Thanks, PB.

That is consistent with my very limited experience.

Testing for an ACK is much the same as WCOL, i.e., ACKSTAT doesn't generate an interrupt. But when the master is transmitting, it doesn't even need to check whether an ACK is received ( see: AN989 by Chris Parris). On the other hand, a write collision prevents any change in the buffer and nothing happens, so I assumed it might be something you would want an interrupt for like exists for a bus collision. And, I was considering using a WDT timeout as a surrogate way of testing WCOL without actually testing WCOL since it will happen very infrequently, if ever.

Maybe I will just leave the test in my code and suffer the small time penalty, or leave it there and comment it out like Parris did with the ACK checks in that application note.

John
 

Papabravo

Joined Feb 24, 2006
21,159
I'm glad the answer off the top of my head was useful. I didn't go pull up the datasheet, because I trusted you to dig in for the details with just a minor push. Good Luck on your project.
 
Top