How to get 0% and 100% duty cycle for PWM using DMA, in STM32F103C8T6.
My board is STM32F103C8T6.
I am generating complementary PWM using TIMER 1 with DMA for changing duty cycle.
to be precise SINE WAVE PWM (or SPWM) using CENTRE ALIGNED MODE 2.
Now i also want to generate SQUARE wave from channel2 , the wave should have time period of DMA length.
so lets say DMA(sPWM) contains 100 elements , channel2 should generate square wave,
which is HIGH for first 50 elements and LOW for last 50 elements of DMA(of sPWM)(see Picture attatched).
Now I know I can't have different frequency on same timer .
To do this I have created another DMA buffer for channel 2 which contains ,
first 50 element equals to ARR and last 50 elements 0.
But if I put 0 or max The generated square period sometime becomes small or extends or sometime stops
HAL_TIM_Base_Start(&htim1);
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *) sinebuffer, 60);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_2, (uint32_t *) sqbuffer, 61);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);.
I can't put ARR-1(in place of ARR) or 1(in place of 0) in second DMA , as there can be short circuit in my circuit due to small wrong pulse.
NOW i don't know how to generate 0% and 100% duty cycle any other way.
Or is there a better way to do this?
Thank You.
