I'm trying to use OSTM1 as a timer. Say I want to toggle a pin every x us.
OSTM1 is set as follow:
void R_OSTM1_Init(void){ /* Disable OSTM1 operation */ OSTM1TT = _OSTM_COUNTER_STOP; /* Set OSTM1 control setting */ OSTM1EMU = _OSTM_DEBUG_STOP; OSTM1CTL = _OSTM_MODE_INTERVAL_TIMER | _OSTM_START_INTERRUPT_DISABLE;}
and started with:
void R_OSTM1_Start(void){ /* Enable OSTM1 operation */ /* Clear OSTM1 interrupt request and enable operation */ ECON_FEINTFEINTFC |= 0x00040000; OSTM1TS = _OSTM_COUNTER_START; }
on dr7f701649_irq.h:
#define FEINT_ENABLE 0x000000F0u#ifndef FEINT_ENABLE#define FEINT_ENABLE 0x00000000u#endif
and on main.c I add:
#pragma ghs interrupt void unused_isr(void){ while(1){} }
#pragma ghs interruptvoid FEINT(void){ NOP(); ECON_FEINTFEINTFC |= 0x00040000; OSTM1_flag = 1;}
I can debug through FEINT but as soon as it leave the function, it got stuck on unused_isr and i had no idea what interrupt is triggered.
Can anyone give me a hint, what went wrong?
Cheers
Arno
Hello,
INTOSTM0 can operate as an EIINT or FEINT interrupt, but using it both ways at the same time is prohibited. When INTOSTM0 is used as FEINT, it is generated by the TSU (timing supervision unit) function of OSTM0. That is why you get the FEINT interrupt.
Hi AZ,
thank you for your reply. Yes it says that on the data sheet. but I'm using OSTM1, so the only interrupt use is FENIT.
It seem the problem is with ghs pragma. According to Green Hills "#pragma ghs interrupt" will create EI-Level interrupt and i assume that is what trigged the unused_isr.
If you want to use FE-Level interrupt, you need to define it as:
#pragma ghs interrupt (FE) void FEINT(void){ //your code here }