Helping in I2C SDK Driver + GPIO Interrupt

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Helping in I2C SDK Driver + GPIO Interrupt

跳至解决方案
738 次查看
matheuspinto
Contributor II

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.

 

70454_70454.pngkkk.png

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:

 

70456_70456.pngkkk.png

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:

 

70459_70459.pngkkk.png

 

The loop used for pooling now is empty, and is used the ISR from PTA14 interrupt to read the samples.

 

70457_70457.pngkkk.png

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.

 

70458_70458.pngkkk.png

 

This occurs only inside the ISR!

 

The project is attached (the comments are in portuguese. Sorry!!!)

Original Attachment has been moved to: mma8451.rar

标签 (1)
0 项奖励
回复
1 解答
578 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
1 回复
579 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复