Hello,
I am trying to do a driver for the freescale mma8451q accelerometer, using the KSDK + KDS 3.0.0 + Processor Expert.
For test, was made a function calling in main.
The function waits a logic 1 in PTA13 to run. There are two options to read the samples from accelerometer:
pooling e interrupt.
First, was tested the pooling mode, where the function constantly reads the samples from accelerometer, setting a LED from LED RGB, corresponding to the axis, using this loop:
The firmware works right and the first test was passed.
In the second test was used the interrupt mode from accelerometer. When a sample is taken from accelerometer, a interrupt, active LOW, is generated in the pin PTA14.
Uncomment this loop, to active interrupt:
The loop used for pooling now is empty, and is used the ISR from PTA14 interrupt to read the samples.
But, when try to read the samples, the accel_GetXYZ function gets stucked in the I2C_DRV_MasterReceive function when try send the address of the slave.
This occurs only inside the ISR!
The project is attached (the comments are in portuguese. Sorry!!!)
Original Attachment has been moved to: mma8451.rar
已解决! 转到解答。
Hello Matheus Pinto:
You must be running in the same problem of the next post:
Re: I2C function failed when called from ISR
It is not recommended to call Driver APIs requiring interrupt handling from inside an ISR. Instead you can use a flag to indicate the code that the interrupt occured, so you can trigger the accelerometer reads.
In the short term try increasing the priority of the I2C interrupts and see if that helps.
Regards!
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Matheus Pinto:
You must be running in the same problem of the next post:
Re: I2C function failed when called from ISR
It is not recommended to call Driver APIs requiring interrupt handling from inside an ISR. Instead you can use a flag to indicate the code that the interrupt occured, so you can trigger the accelerometer reads.
In the short term try increasing the priority of the I2C interrupts and see if that helps.
Regards!
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------