SCT counter debug

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

SCT counter debug

631 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kitahei88 on Fri Sep 25 19:02:15 MST 2015
Hello,all.
I want to debug SCT counter with LPCXpressoIDE.
It may be FAQ or beginner question.

I use LPCXpresso1549 RevB board.
I want to know " when MATCH register reload from MATCHRELOAD reg?"
Of course , I read user manual and it says,

Quote:

    "Each match reload register MATCHRELOAD sets a reload value that is loaded into the match register when the counter reaches
    a limit condition or the value 0."


But I want to know "Is it true?"
So I write code like this

#include "LPC15xx.h"

void SCT0_Init(void)
{
    LPC_SYSCON->SYSAHBCLKCTRL1 |= EN1_SCT0;            // enable the SCT0 clock
    LPC_SCT0->CONFIG            = (1 << 0)    | (1 << 17);    // unified 32-bit timer, auto limit

    // Timer Limit set to 10msec
    LPC_SCT0->MATCH[0].U        = (SystemCoreClock/100)-1;  // match 0 @ 100 Hz 
    LPC_SCT0->MATCHREL[0].U     = (SystemCoreClock/100)-1;
   
    // Check MATCH and MATCHRELOAD reg work
    LPC_SCT0->MATCH[1].U        = (SystemCoreClock/10000)-1;
    LPC_SCT0->MATCHREL[1].U     = (SystemCoreClock/1000)-1;
   
    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 SCT0 interrupt

    LPC_SCT0->CTRL_U &= ~(1 << 2);                      // clear HALT status
}


And I debug with LPCXpressoIDE, CMSIS-DAP,LPC-Link2.

I check the value MATCH[0].U ,MATCHREL[0].U,MATCH[1].U,MATCHREL[1].U with Expression.
After SCT halt condition cleared, SCT works very quick , and debugging next line, the timer already reached LIMIT (in many times).
Expression shows MATCH[1].U reg already reloaded.

So I want to make break at certain counter value , How can I do that? or it's impossible?
Or any other debug method like SWO trace can do that?
0 Kudos
Reply
0 Replies