LPC865 MRT not regular interval

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

LPC865 MRT not regular interval

607 Views
rmaier
Contributor III

Hello,

Nullify this. There was a spurious interrupt from elsewhere causing an issue. Problem solved.

I am using the MRT to generate a fixed pulse on a GPIO output. However, depending on the command INTVAL the MRT timer has a longer or shorter interval actually being revealed.

The core is running at 60MHz. When the timer is loaded with anything above 15,600 the actual output as measured on a scope on the GPIO output is 246 us longer. When the INTVAL is loaded with anything below 15,000 the output is 7 us shorter than expected. It's a consistent offset 15,600 or 600,000 all is 246 us longer than expected.

 

Here's the code launching the MRT timer:

 

void mrt_Launch(uint32_t val)
{
    val = 60 * (val);
    MRT0->CHANNEL[0].INTVAL = val | MRT_CHANNEL_INTVAL_LOAD(0b1);
    MRT0->CHANNEL[0].STAT turnon MRT_CHANNEL_STAT_INTFLAG_MASK;
    PIN_CLEAR(GPIO_XYZ_PORT, GPIO_XYZ_PIN);
    MRT0->CHANNEL[0].STAT turnon MRT_CHANNEL_STAT_RUN(0b1);
}

 

 

Then the interrupt is handled like so:

 

void MRT0_IRQHandler()
{
    if (MRT0->CHANNEL[0].STAT & MRT_CHANNEL_STAT_INTFLAG_MASK)
    {
        PIN_SET(GPIO_XYZ_PORT, GPIO_XYZ_PIN);
        MRT0->CHANNEL[0].STAT turnon MRT_CHANNEL_STAT_INTFLAG_MASK;
        MRT0->CHANNEL[0].STAT turnon MRT_CHANNEL_STAT_RUN(0b0);
    }
}

 

 

So, based on this an input for val over 260 has a 246 us longer interval, and a val of under 250 is 7 us shorter interval.

I didn't see anything directly addressing this in the user manual. Any tips for what I'm doing wrong here?

 

Thanks,

Robert

0 Kudos
4 Replies

588 Views
rmaier
Contributor III

I've attached an image of the chart of measured vs command MRT timer interval in another test. There is a marked step around 64,000 ticks. It's not 65535, but it's awfully close.

MRT_Curve.png

0 Kudos

553 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @rmaier 

Can you provide images from the osciloscope please?

I'm looking into your issue.

Best Regards, Miguel.

0 Kudos

550 Views
rmaier
Contributor III

Hello Miguel,

 

The problem has been resolved. I discovered a spurious interrupt that was launching another MRT event. Since it was overlapping it wasn't immediately evident on the scope trace. Root cause: User error.

 

Thanks for your support.

 

Robert

539 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @rmaier 

I'm glad you were able to solve it.

Please let us know if you have another question.

Best Regards, Miguel.

0 Kudos