Hi, I'm using MRT on LPC832 (SDK: 2.16.000), and if I call the following, the interrupt for channel 1 does actually happen, and the flags for RUN and INT are set. To ignore channel 1, I have to test for MRT_GetEnabledInterrupts() in the interrupt handler. Which is Ok, because it works, but it seems counter-intuitive that if I say "disable interrupts for channel 1," the interrupt is still actually enabled. Or am I doing something wrong?
Thanks!
void MRT0_DriverIRQHandler(void)
{
if ( MRT_GetStatusFlags( MRT0, kMRT_Channel_0 ) == (MRT_CHANNEL_STAT_INTFLAG_MASK | MRT_CHANNEL_STAT_RUN_MASK) ) {
MRT_ClearStatusFlags( MRT0, kMRT_Channel_0, kMRT_TimerInterruptFlag );
g_doPWM = 0;
g_LED0 = !g_LED0;
GPIO_PinWrite( g_pins[0].gpio.base, g_pins[0].gpio.port, g_pins[0].gpio.pin, g_LED0 );
}
if ( MRT_GetEnabledInterrupts( MRT0, kMRT_Channel_1 ) ) {
if ( MRT_GetStatusFlags( MRT0, kMRT_Channel_1 ) == (MRT_CHANNEL_STAT_INTFLAG_MASK | MRT_CHANNEL_STAT_RUN_MASK) ) {
MRT_ClearStatusFlags( MRT0, kMRT_Channel_1, kMRT_TimerInterruptFlag );
g_doPWM = 0;
g_LED1 = !g_LED1;
GPIO_PinWrite( g_pins[3].gpio.base, g_pins[3].gpio.port, g_pins[3].gpio.pin, g_LED1 );
}
}
SDK_ISR_EXIT_BARRIER;
}
/*
* @brief Application entry point.
*/
int main(void) {
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
mrt_config_t defaultMRTConfig;
MRT_GetDefaultConfig( &defaultMRTConfig );
MRT_Init( MRT0, &defaultMRTConfig );
MRT_SetupChannelMode( MRT0, kMRT_Channel_0, kMRT_RepeatMode );
MRT_SetupChannelMode( MRT0, kMRT_Channel_1, kMRT_RepeatMode );
MRT_UpdateTimerPeriod( MRT0, kMRT_Channel_0, MRTINTERVAL, 1 );
MRT_UpdateTimerPeriod( MRT0, kMRT_Channel_1, SYSCLOCK, 1 );
MRT_EnableInterrupts( MRT0, kMRT_Channel_0, kMRT_TimerInterruptEnable );
MRT_DisableInterrupts( MRT0, kMRT_Channel_1, kMRT_TimerInterruptEnable );
EnableIRQ( MRT0_IRQn ); /* Normally, this would be called in peripherals.c */
Hello, I did a simple test with the part of the code that you upload, but I need more information, could you open an Internal case put my name I will take it, because I need you share the whole project or the whole main.c. I think replay the same issue that you report on my board.
Let me know what you do.
Best regards,
Pavel
Hey, Pavel, the entire code base can be found here, but it's not that important, I guess. I can work around it. I just wanted to understand the "why" behind the way it works, since it's somewhat unintuitive, but since I can work around it, it's less critical, now.
Feel free to close this one out.
Hello, my name is Pavel and I will be supporting your case, I reviwed the example on the SDK LPCOpen on the IDE MCUXpresso and this use the next to active.
/* Enable the interrupt for the MRT */
NVIC_EnableIRQ(MRT_IRQn);
And on bellow of this there is
void NVIC_DisableIRQ(IRQn_Type IRQn)
Could you try with this.
I couldn't find the function of MRT_GetEnabledInterrupts.
Best regards,
Pavel
Hi Pavel,
NVIC_DisableIRQ() will definitely shut off the interrupt for MRT, but it will shut off *all* interrupts for MRT. The LPC832 has 4 channels for MRT, and they're all enabled or disabled, with NVIC_EnableIRQ() or disable, as above.
However, in the MRT peripheral, there's a MRT_DisableInterrupts() that should, I assume, disable a particular MRT channel, as needed. So if I configure two MRT channels, and then want to stop one of them, MRT_DisableInterrupts() should do that. However, in the interrupt handler,
MRT_GetStatusFlags( MRT0, kMRT_Channel_1 ) == (MRT_CHANNEL_STAT_INTFLAG_MASK | MRT_CHANNEL_STAT_RUN_MASK) )
returns true, even if channel 1 has had its interrupt disabled. This following check in the ISR will block the ISR portion for channel 1 from executing, but I'm wondering why the channel was hardware triggered in the first place, if the channel was disabled.
if ( MRT_GetEnabledInterrupts( MRT0, kMRT_Channel_1 ) )
SDK documentation is here: https://mcuxpresso.nxp.com/api_doc/dev/4555/a00017.html#gafa8493a0faee1cc356da26ca99a54da8
Like I said, I can work around this, but I'm curious if this is how it's supposed to work.
Hello, I'm using the SDK of LPCOpen on the MCUXpresso and that library is not added, where are you develop this? Could you share the source of this example?
Best regards,
Pavel
Hi Pavel,
Sorry for the delay: I was out of town for the weekend. I got the SDK from NXP's SDK Builder: https://mcuxpresso.nxp.com/en
Go there, select "Select Board / Processor"; enter "LPC832," and then build your SDk. Current version is 2.16.000.
Aaron
Hello, thanks for the information I was using the LPCOpen, I will download and reviewed.
Best regards,
Pavel