2 Replies Latest reply on Apr 14, 2016 12:20 PM by userc_40175

    I2C after WDT interrupt

      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).

        • 1. Re: I2C after WDT interrupt

          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

          • 2. Re: I2C after WDT interrupt

            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?