Helping in I2C SDK Driver + GPIO Interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Helping in I2C SDK Driver + GPIO Interrupt

Jump to solution
1,087 Views
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

Labels (1)
0 Kudos
Reply
1 Solution
927 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
1 Reply
928 Views
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 Kudos
Reply