void SCT0_PWM(void)
{
SYSCON->AHBCLKCTRLX[1]|=(1<<2); //SET SCT0 bit
//configure the SCT clock source
SYSCON->SCTCLKSEL=0; //main clock is the SCT driving clock
SCT0->CONFIG = (1 << 0) | (1 << 17); // unified 32-bit timer, auto limit
SCT0->MATCHREL[0] = SystemCoreClock/100; // match 0 @ 100 Hz = 10 msec
SCT0->EV[0].STATE = 0xFFFFFFFF; // event 0 happens in all states
//set event1
SCT0->MATCHREL[1]=0x00;
SCT0->EV[1].STATE = 0xFFFFFFFF; // event 1 happens in all states
SCT0->EV[1].CTRL = (1 << 12)|(1<<0); // match 1 condition only
//PWM output1 signal
SCT0->OUT[1].SET = (1 << 1); // event 1 will set SCT1_OUT0
SCT0->OUT[1].CLR = (1 << 2); // event 2 will clear SCT1_OUT0
SCT0->RES |= (3 << 2); // output 0 toggles on conflict
//PWM output2 signal
SCT0->OUT[2].SET = (1 << 3); // event 3 will set SCT1_OUT0
SCT0->OUT[2].CLR = (1 << 4); // event 4 will clear SCT1_OUT0
SCT0->RES = (3 << 4); // output 0 toggles on conflict
//PWM start
SCT0->CTRL &= ~(1 << 2); // unhalt by clearing bit 2 of the CTRL
}
//Pin initialization code:
//PIO0_8 PIO0_8 FC2_RXD_SDA_MOSI SCT0_OUT1 CTIMER0_MAT3
//PIO0_9 PIO0_9 FC2_TXD_SCL_MISO SCT0_OUT2 CTIMER3_CAP0 - FC3_CTS_SDA_SSEL0
void SCTimerPinInit(void)
{
//Enable the SCTimer clock
SYSCON->AHBCLKCTRLX[0]|=(1<<13); //set IOCON bit
//SCTimer pin assignment
IOCON->PIO[0][18]=0x104;
IOCON->PIO[0][19]=0x104;
IOCON->PIO[0][20]=0x104;
}