lpcware

Problem with SCT for a simple timer

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by salamlora1 on Wed Jan 08 00:11:28 MST 2014
Problem with SCT for a simple timer
Hi
back again with another problem :-D
I’m trying to run a 128 khz period cycle on pin0_7 whit SCT and my processor is LPC812M101JD16 and using the internal crystal
I’m writhe the program below but it’s not work
     SCT_delay=1000000;
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8); //enable the clock for sct 92.1.18
    LPC_SYSCON->PRESETCTRL |= ( 1<< 8); // clear the sct resset pins  92.1.18
    LPC_SWM->PINASSIGN6 |= (111<<24) ; // set the pin0_7 to output
    LPC_SCT->CONFIG = (LPC_SCT->CONFIG & ~0x00060001);
    LPC_SCT->REGMODE_L = 0x00000000;
    LPC_SCT->MATCH[0].U = SCT_delay;
    LPC_SCT->MATCHREL[0].U = SCT_delay;
    LPC_SCT->OUT[0].SET = 0x00000001;
    LPC_SCT->OUT[0].CLR = 0x00000002;
    /* Initial state of CTOUT_0 is 0 */
    LPC_SCT->OUTPUT = (LPC_SCT->OUTPUT & ~0x00000001) | 0x00000000;
    LPC_SCT->EVENT[0].CTRL = 0x0000D000; /* match[0] causes transition to State 1 */
    LPC_SCT->EVENT[0].STATE = 0x00000001; /* Event[0] occurs in State 0 */
    LPC_SCT->EVENT[1].CTRL = 0x00005000; /* Event 0 on Match[0]. Load State 0 */
    LPC_SCT->EVENT[1].STATE = 0x00000002; /* Event[1] occurs in State 1 */
    LPC_SCT->STATE_L = 0;
    LPC_SCT->LIMIT_L = 0x00000003; /* EVENTS 0 and 1 cause a timer limit */




Outcomes