AnsweredAssumed Answered

LPC15 SCT problem

Question asked by Greg Wilson-Lindberg on Jun 2, 2017
Latest reply on Jun 6, 2017 by Greg Wilson-Lindberg

I'm trying to get the SCT running on an LPC1519 based board. I've got the SCT running propery on another board based on the LPC1517 and it is working just fine. I haven't been able to get anything working with the SCT on the LPC1519 based board.

 

I went back to the AN11538 SCT Cookbook to make sure that I understood what is happening and I can't get the first two demos to work at all. Here is the code that I'm using for the first demo, a 10ms interrupt:

void SCT_Init(void)
{
   LPC_SCT0->CONFIG = (1 << 0) | (1 << 17);                      // unified 32-bit timer, auto limit
   LPC_SCT0->MATCHREL[0].U = SystemCoreClock/100;    // match 0 @ 100 Hz = 10 msec
   LPC_SCT0->EVENT[0].STATE = 0xFFFFFFFF;                   // event 0 happens in all states
   LPC_SCT0->EVENT[0].CTRL = (1 << 12);                         // match 0 condition only
   LPC_SCT0->EVEN = (1 << 0);                                           // event 0 generates an interrupt
   NVIC_EnableIRQ(SCT0_IRQn);                                           // enable SCTimer/PWM interrupt
   LPC_SCT0->CTRL_U &= ~(1 << 2);                                     // unhalt by clearing bit 2 of the CTRL
}

 

And the interrupt handler:

void SCT0_IRQHandler(void)
{
   LPC_SCT0->EVFLAG = SCT_EVT_0; // clear Event 0 irq
   LPC_SCT0->EVFLAG = SCT_EVT_1; // clear Event 1 irq
}

When I put a breakpoint in the interrupt handler it never gets triggered. I know that there is something missing, but at this point I can't see it.

 

I've also tried the 2nd example to blink a LED to try to toggle an output line (PIO2_3) and I don't get anything for that either:

{
   LPC_SCT0->CONFIG |= 1; // unified timer
   LPC_SCT0->MATCHREL[0].U = (SystemCoreClock/10)-1; // match 0 @ 10 Hz = 100 msec
   LPC_SCT0->EVENT[0].STATE = (1 << 0); // event 0 only happens in state 0
   LPC_SCT0->EVENT[0].CTRL = (0 << 0) | // related to match 0
         (1 << 12) | // COMBMODE[13:12] = match condition only
         (1 << 14) | // STATELD[14] = STATEV is loaded into state
         (1 << 15); // STATEV[15] = 1 (new state is 1)
   LPC_SCT0->EVENT[1].STATE = (1 << 1); // event 1 only happens in state 1
   LPC_SCT0->EVENT[1].CTRL = (0 << 0) | // related to match 0
         (1 << 12) | // COMBMODE[13:12] = match condition only
         (1 << 14) | // STATELD[14] = STATEV is loaded into state
         (0 << 15); // STATEV[15] = 0 (new state is 0)
   LPC_SCT0->OUT[0].SET = (1 << 0); // event 0 will set SCT_OUT0
   LPC_SCT0->OUT[0].CLR = (1 << 1); // event 1 will clear SCT_OUT0
   LPC_SCT0->LIMIT_L = 0x0003; // events 0 and 1 are used as counter limit
   LPC_SCT0->CTRL_L &= ~(1 << 2); // unhalt by clearing bit 2 of CTRL register

   Chip_SWM_MovablePinAssign(SWM_SCT0_OUT0_O, 0x43);
}

 

I'm using the MCUXpresso IDE v10.0.0. Both examples were copied out of the AN11538 App Note and only modified to changed the LPC_SCT-> pointers to LPC_SCT0-> for the LPC1519 processor.  For the Blinky example I added the call to assign the SCT0_OUT0_O output to PIO2_3.

 

Any help anyone could give me would be greatly appreciated.

Outcomes