Can't use umplOnTimer() function in an interrupt routine

By vincent_chardon , 10 July 2012

Hi,
I am trying to periodically read sensor values from MPU-6050 rev c. I have setup a timer based interrupt that calls a function (ISR) every 10th millisec. I want the values to be precisely 10msec apart. Now my interrupt service routine doesn't work and hangs at the function umplOnTimer(). When i comment the umplOntimer() function, the interrupt starts working. What is wrong here? Thanks in advance.

vrmmeh

13 years 8 months ago

@omer_qureshi wrote:

When i comment the umplOntimer() function, the interrupt starts working. What is wrong here?

The umplOnTimer() function probably has code which requires its own interrupts to run properly. Can you set a flag inside your interrupt routine, then simply poll in an infinite main loop and call umplOnTimer() there whenever the flag is set? I believe this is the preferred way to deal with interrupt-driven events; there should be absolutely as little code as possible inside the actual interrupt routine, since it stops almost everything else from happening.

Also, can you set the output rate on the MPU to 100Hz and use the INT pin to trigger an external interrupt when FIFO data is ready, rather than relying on timer-based internal interrupt generation? This might be simpler...but maybe it isn't precise enough?
phpbb Post ID
20676

guy_mcilroy

13 years 8 months ago

The MPU device can be set up to perform 100 Hz data collection accurately using either interrupt or enabling the FiFo to allow your device to collect data at a slower rate. For your own timing function, you should verify that you are not using the same device timer that is configured for your eMPL library.

phpbb Post ID
20679

vincent_chardon

13 years 8 months ago

Thanks for replying.
@sectionsbest wrote:

The MPU device can be set up to perform 100 Hz data collection accurately using either interrupt or enabling the FiFo to allow your device to collect data at a slower rate.

You mean configuring the FIFO rate to 100Hz and then using INT pin with Data ready DATA_RDY_EN interrupt?
@sectionsbest wrote:

For your own timing function, you should verify that you are not using the same device timer that is configured for your eMPL library.

Can u describe a quick way to find that?
Thanks
phpbb Post ID
20682

guy_mcilroy

13 years 8 months ago

You could set up the Fifo rate at 100 Hz, then use DATA_RDY_EN, or have your device wait for a longer period of time, then wake up and empty the Fifo buffer. As long as the Fifo overflow interrupt hasn't been triggered, you won't lose any data. For device timer info, check out "msp430_timer.h" for detail on the timers used by eMPL.

phpbb Post ID
20685
phpbb Topic ID
14508