TIM1 one-pulse PWM mode with four outputs -- I would like the pulses to start HIGH immediately when I enable the timer, so that they can go LOW individually at different times depending on each comparison.
I'm a beginner at STM8 programming. I'm designing a quad trailing-edge dimmer as my first STM8S003F3 project. I have a zero crossing pulse tied to a pin and generating an interrupt, and on this interrupt I want to trigger pulses on four output that end at the correct time (to achieve mains PWM dimming).
So far I am testing with a very slow one-pulse timer and an LED, initialized as follows:
TIM1_DeInit();
TIM1_TimeBaseInit(2000, TIM1_COUNTERMODE_UP, 0x7FF, 0);
TIM1_OC3Init(TIM1_OCMODE_PWM2, TIM1_OUTPUTSTATE_ENABLE, TIM1_OUTPUTNSTATE_DISABLE, 0x3FF, TIM1_OCPOLARITY_HIGH, TIM1_OCNPOLARITY_HIGH, TIM1_OCIDLESTATE_RESET, TIM1_OCNIDLESTATE_RESET);
TIM1_SelectOnePulseMode(TIM1_OPMODE_SINGLE);
TIM1_GenerateEvent(TIM1_EVENTSOURCE_UPDATE);
TIM1_CtrlPWMOutputs(ENABLE);
TIM1_Cmd(ENABLE);Then once per second I call TIM1_Cmd(ENABLE); and get one pulse -- but the start of the pulse is of course delayed (pulse length 3ff).
By setting pulse length 1, the delay goes away and I can adjust the pulse length in TimeBaseInit, but then I of course cannot set the four TIM1 outputs differently.
I've tried many different things but I'm in over my head, just starting out.
If there's a way to set the output HIGH and let it stay HIGH until the comparison brings it LOW then this would solve my problem.
I would really appreciate any pointers in the right direction. Thanks in advance!
