AnsweredAssumed Answered

Question - How to generate PPM signal with a Timer

Question asked by anton.bogdan on Jun 20, 2016
Latest reply on Jun 20, 2016 by Clive One
Hello all,
i own a stm32F103c8x device, and since i am a maniac with rc toys, i am working on a ppm generator.
Right now i am working with  a 16bit timer ( timer3) and for example i put 6 random ppm values, and i expect 6 diferent dutycyles on the same pwm signal...

so i configure the time base like this
TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCStruct;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM3 , ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE);
       GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_0;//
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
      GPIO_Init(GPIOB, &GPIO_InitStructure);
TIM_TimeBaseStructure.TIM_Prescaler = 72-1;// 65000;
     TIM_TimeBaseStructure.TIM_Period = 2300;
     TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
     TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
     TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_TimeBaseInit(TIM3 , &TIM_TimeBaseStructure);
TIM_OCStruct.TIM_OCMode = TIM_OCMode_PWM2;
TIM_OCStruct.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCStruct.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCStruct.TIM_Pulse = 0;
    TIM_OC3Init(TIM3, &TIM_OCStruct);
    TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Enable);

and in my main loop i have this :

uint16_t pwm_array[6]={1000,1500,1450,1200,1890,1991};

for(int ii=0; ii<6;) {
    TIM3->CCR3 = pwm_array;

So on ch3 ( PB0) on timer3 i would expect to have the fist pulse of 1000us, 2nd 1500us and so on... but its not working as expected, i always have 1500us...
This is my first time i atempt to generate ppm and i would like to know some advices,