I am using the TRK-MPC5634M board and Codewarrior to test an output compare.
I need to know when the OC is done, so I can check some other things.
eTPU->CHAN[0].SCR.B.CIS indicates that the interrupt has fired in the ETPU.
What am I missing in order to route the interrupt back to the processor?
Thanks
partial below
void main(void)
{
init();
test();
while(1){};
}
void init(void)
{
etpuInit();
INTC_InitINTCInterrupts();
INTC_InstallINTCInterruptHandler(etpu_0_ISR, 68, 5); // interrupt for ETPU_0 (68)
fs_etpu_interrupt_enable(0);
fs_etpu_clear_chan_interrupt_flag(0);
INTC .CPR.R = 0;
asm(" wrteei 1");
}
void test(void)
{
SIU .GPDO[ETPU_A1_PIN].R ^= 1; // toggle output so I can see start
fs_etpu_oc_init_immed(0, // channel
FS_ETPU_PRIORITY_HIGH, // priority
FS_OC_MATCH_TCR1, // match timebase
1000, // offset1
FS_ETPU_OC_PIN_HIGH_CAPTURE_TCR1, // pin action
10000, // offset2
FS_ETPU_OC_PIN_LOW_CAPTURE_TCR1, // pin action
FS_ETPU_OC_INIT_PIN_NO_CHANGE); // init pin
fs_etpu_clear_chan_interrupt_flag(0);
}
void etpu_0_ISR(void)
{
SIU .GPDO[ETPU_A1_PIN ].R ^= 1;
fs_etpu_clear_chan_interrupt_flag(0);
}
I finally figured out what I was missing. The default OC does not enable the interrupt.
If I add ETPU.CIER_A.B.CIE0=1 the interrupt fires at the end if the event. Just what I needed.
Hi, I don't see anything obvious from this code snippet. OC function works fine in other aspects? And have you tried other interrupt sources (for instance PIT) to check whether you have properly working interrupts?
Other interrupts work fine. The OC works (i.e. the output toggles when it should). I just can't get the interrupt to fire.
I have just tried it and it works fine on my side.
I can share example code if needed
Please share your code.
I am currently at home office without any hardware to check it but I believe I have attached the right code. Certain configuration in the main function, the rest configured with eTPU GCT, config file in the /src folder. Note that it is just raw state without any comments.
I ran your code. The interrupt does fire, but only once. At power-up the OC and the interrupt fire, but if you reload the OC (change I made) the interrupt does not fire. I checked eTPU->CISR_A.B.CIS0 and it was still 1. I cleared it again (got 0) and the interrupt still did not fire again.
It is not supposed to.
If you need periodic pulses, use function QOM function:
I will look at that. What I want is a way to detect when the OC is done. (without polling it), so I can load it with the next event.
I guess I don't understand the purpose/implementation of the OC interrupt.