This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWI function not working when Called from a Pin Interrupt Handler

Hi,

The program I'm testing is mainly based on the example code Martin provided in devzone.nordicsemi.com/.../

First test was that to read sensor data (MPU6050) by programming the nRF to request the data. This was successful.

Second test was to program MPU6050 to generate interrupts and then read the data. Monitoring a couple of pins and TWI pins showed that

  • MPU6050 was programmed correctly and the INT pulses could be seen
  • Code will go to the pin interrupt handler and the read acceleration function is called
  • TX part of the read operation (sending the slave address and the register address) is done, but RX part doesn't go through (no activity on SDA and SCL lines, and I think it eventually timeout)

In all these cases, read_accel() function was called from inside the int_pin_handler. When I tried calling the read function from main() the issue was solved and data can be read correctly.

Any thoughts on why is it acting like this? My SDK is 9, chip revision 3 and level 3 optimization is used.

main-2016-02-19.c mpu9150.c

Related