I2C after WDT interrupt

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I'm attempting to interface with a set of I2C sensors (accelerometer/magnetometer & temperature/humidity) and for whatever reason I have not been able to get the I2C bus to work off of a watchdog interrupt. If I attempt to communicate with either of the sensors before the first WDT interrupt, there is no issue, but the core will lock up or reset afterwards.

   

Everything else has generally worked within the ISR routine (ADC read, UART transfer) but the I2C hasn't. I've tried using the CriticalSection API, starting and restarting the I2C bus, disabling and re-enabling the WDT, and disabling sleep modes to no avail. Any insight into this issue would be appreciated. Thanks!

   

I have some sample code attached that has a lot of unrelated functionality removed (UART, BLE, etc).

0 Likes
1 Solution
Anonymous
Not applicable

Hi,

   

Can you please move the ADC and I2C sensor measuement parts out of the ISR? Instead of calling them directly in the ISR, please set a flag inside ISR when ISR is triggered. In the main()'s while loop, keep checking the status of this flag and perform ADC and I2C sensor operatios when this flag is set true. 

   

Regards,

   

-Madhu Sudhan

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Hi,

   

Can you please move the ADC and I2C sensor measuement parts out of the ISR? Instead of calling them directly in the ISR, please set a flag inside ISR when ISR is triggered. In the main()'s while loop, keep checking the status of this flag and perform ADC and I2C sensor operatios when this flag is set true. 

   

Regards,

   

-Madhu Sudhan

0 Likes
Anonymous
Not applicable

Madhu,

   

Thanks for the information. I moved all of the code to the main loop and it worked without issue. I assume that most commands won't be able to execute if inside the ISR?

0 Likes