AnsweredAssumed Answered

LPC54102 - SCT does not interrupt for each event wanted!

Question asked by Doinita Marcu on Sep 15, 2016
Latest reply on Sep 20, 2016 by Doinita Marcu

Hi,

I want SCT of LPC54102 to interrupt 3 times on 3 distinguished events, but it will interrupt only one time showing flags of interrupts for all of them in the EVFLAG register. And when I clear one flag, it will clear all.

I mention that I set each event to happen only on a match condition, and the 3 events have different matching values.

I copy the code here:

The interrupt soubroutine:

 

void SCT0_IRQHandler(void)
{

numInt++;
evFlag = LPC_SCT->EVFLAG;

if ( LPC_SCT->EVFLAG & SCT_EVT_0)
{
numInt0++;
Chip_SCT_ClearEventFlag(LPC_SCT, SCT_EVT_0);
evFlag0 = LPC_SCT->EVFLAG;
}
if ( LPC_SCT->EVFLAG & SCT_EVT_1)
{
numInt1++;
Chip_SCT_ClearEventFlag(LPC_SCT, SCT_EVT_1);
evFlag1 = LPC_SCT->EVFLAG;
}
if ( LPC_SCT->EVFLAG & SCT_EVT_2)
{
numInt2++;
Chip_SCT_ClearEventFlag(LPC_SCT, SCT_EVT_2);
evFlag2 = LPC_SCT->EVFLAG;
}

}

 

I display the variables incremented inside the ISR, and I can see that numInt = numInt0 = 1, evFlag = 0x7, and after first clear evFlag0 = 0x00. Never it will reach the other checking.

So it will interrupt only one time instead of 3 times at different time values.

And here it is the code of initialization:

 

 Chip_SCT_Init(LPC_SCT);

Chip_SCT_Config(LPC_SCT,
SCT_CONFIG_32BIT_COUNTER | SCT_CONFIG_CLKMODE_BUSCLK);

 Chip_SCT_SetMatchCount(LPC_SCT, SCT_MATCH_0, 100);

LPC_SCT->EVENT[0].CTRL = (1 << 12);

LPC_SCT->EVENT[0].STATE = 0x00000001;

Chip_SCT_SetMatchCount(LPC_SCT, SCT_MATCH_1, 200);
LPC_SCT->EVENT[1].CTRL = (1 << 12);
LPC_SCT->EVENT[1].STATE = 0x00000001;

Chip_SCT_SetMatchCount(LPC_SCT, SCT_MATCH_2, 300);
LPC_SCT->EVENT[2].CTRL = (1 << 12);
LPC_SCT->EVENT[2].STATE = 0x00000001;

Chip_SCT_EnableEventInt(LPC_SCT, SCT_EVT_0);
Chip_SCT_EnableEventInt(LPC_SCT, SCT_EVT_1);
Chip_SCT_EnableEventInt(LPC_SCT, SCT_EVT_2);

NVIC_EnableIRQ(SCT0_IRQn);

Chip_SCT_ClearControl(LPC_SCT, SCT_CTRL_HALT_L);

 

I would really apreciate some help.

 

Thank you,

Doini

Outcomes