LPC54102 - SCT does not interrupt for each event wanted!

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

LPC54102 - SCT does not interrupt for each event wanted!

1,263 Views
doini
Contributor III

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

0 Kudos
4 Replies

801 Views
doini
Contributor III

Hi Rolf,

Thank you for your reply, it was useful.

I set a MATCH register for each event and it worked for one of my examples.

But when I set the 3 SCT events to interrupt at very small intervals of time, in the order of several hundred nano-seconds (the system frequency is 96MHz), it interrupted only one time with the flags set for all 3 events.

And I have this problem also with the DMA interrupts on 3 channels triggered at very small intervals of time, which interrupt only one time and not 3 times. I posted a question about that with the title: LPC54102 - DMA on 3 channels interrupts only one time instead of 3 times! on this forum, would you like to take a look at that?

I would really appreciate your help.

Thank you,

Doinita

0 Kudos

801 Views
doini
Contributor III

Hi Rolf,

Thank you for your answer, I modified that to Right:     pSCT->EVFLAG = evt;

But still my problem persist: The program is supposed to interrupt first time after MATCH_0 (100) counts, to interrupt the second time after MATCH_1 (200) counts, and to interrupt the third time after MATCH_2 (300) counts.

But it will interrupt only after MATCH_0 (100) counts, the EVFLAG shows 3 pending interrupts, and after that it will not interrupt at 200 and 300 counts anymore.

If I clear only one interrupt in the ISR, it will interrupt right away with the other pending flags, and again until all flags are cleared, but still the COUNT shows 100, and never will interrupt at 200 and 300 counts.

I would really appreciate any help.

 

Thank you,

Doini

0 Kudos

801 Views
rolfmeeser
NXP Employee
NXP Employee

Hi Doini,

Ok, so individual acknowledge of events is now working, that's fine.

Looking closer at your initialization code, I saw that all your events are triggered at the same time! Example:

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

This leaves the MATCHSEL field unconfigured (=0), which means that event 2 (like event 0 and event 1) is triggered by a match of the counter with MATCH0.

I guess what you want is this:

LPC_SCT->EVENT[2].CTRL = (1 << 12) | (2 << 0);  // Compare with MATCH2

Rolf

0 Kudos

801 Views
rolfmeeser
NXP Employee
NXP Employee

Check the implementation of the Chip_SCT_ClearEventFlag function. It should contain a plain assignment to EVFLAG, not a read-modify-write operation.

Wrong:    pSCT->EVFLAG |= evt;

Right:     pSCT->EVFLAG = evt;

I've seen that mistake in other LPCOpen versions before, not sure about the LPC5410x version though.

0 Kudos