AnsweredAssumed Answered

LPC1837 SCT Timer PWM Duty Problem

Question asked by Ertuğrul Kocaağa on Jul 26, 2018
Latest reply on Jul 27, 2018 by Ertuğrul Kocaağa

Hello there,

I am trying to use SCT timer to produce one channel pwm for my project. I have used the cookbook as reference. I am setting duty cycle as I wish but when I set the duty cycle to 0%  (LPC_SCT->MATCHREL[1].L = 0) I saw mini pulses. I measured them and I saw that they were at 10MHz, meaning of SCT clock frequency. So SCT first starts the pwm as high and although the duty value is zero it takes 100ns to understand and clears the output. So actually, I can never get 0% even if I set duty register to 0. How can I proceed from now on? Is it a code bug or peripheral bug?

 

Thanks in advance,

Ertuğrul Kocaağa

 

 

   //PWM PIN CONFIGURATION
    SCU_PinConfigure(1, 7,  (SCU_CFG_MODE_FUNC2 | SCU_PIN_CFG_PULLDOWN_EN));
    
    LPC_SCT->CONFIG |= (1 << 17); // two 16-bit timers, auto limit
    LPC_SCT->CTRL_L |= ((18-1) << 5); // set prescaler, SCTimer/PWM clock = 10 MHz
    
    LPC_SCT->MATCHREL[0].L = 10000-1; // match 0 @ 10/1MHz = 1 msec (1 kHz PWM freq)
    LPC_SCT->MATCHREL[1].L = 5000; // match 1 used for duty cycle
    
    LPC_SCT->EVENT[0].STATE = 0xFFFFFFFF; // event 0 happens in all states
    LPC_SCT->EVENT[0].CTRL = (1 << 12); // match 0 condition only
    
    LPC_SCT->EVENT[1].STATE = 0xFFFFFFFF; // event 1 happens in all states
    LPC_SCT->EVENT[1].CTRL = (1 << 0) | (1 << 12); // match 1 condition only
    
    LPC_SCT->OUT[13].SET = (1 << 0); // event 0 will set SCTx_OUT13
    LPC_SCT->OUT[13].CLR = (1 << 1); // event 1 will clear SCTx_OUT13
    
    LPC_SCT->CTRL_L &= ~(1 << 2); // unhalt it by clearing bit 2 of CTRL reg

Outcomes