cancel
Showing results for 
Search instead for 
Did you mean: 

PWM control with DMA and ADC

esiqueira
Associate II
Posted on June 21, 2012 at 16:58

The original post was too long to process during our migration. Please click on the attachment to read the original post.
2 REPLIES 2
Posted on June 21, 2012 at 17:23

Don't know about the general viability of this

But you'll need to fix the Channel# here

 TIM_OC3Init(TIM4, &TIM_OCInitStructure);      // Initializes the TIM Channel 3 according to the parameters specified in the TIM_OCInitStruct
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
esiqueira
Associate II
Posted on June 21, 2012 at 20:01

THANKS!!! clive1,,,

%%%%% BELOW THE SOLUTION%%%%%%%%

void TIM_Configuration(void)

 /* Time base configuration */

 TIM_TimeBaseStructure.TIM_Period = 0xFFF;

 TIM_TimeBaseStructure.TIM_Prescaler = 3000;

 TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;

 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

 TIM_TimeBaseStructure.TIM_RepetitionCounter = 1;

 TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);

 

 /* PWM1 Mode configuration: Channel1 */

 TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;

 TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;

 TIM_OCInitStructure.TIM_Pulse = 50;

 TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

 

 TIM_OC3Init(TIM4, &TIM_OCInitStructure);

 

 TIM_ARRPreloadConfig(TIM4, ENABLE);

 

    // ''connecting'' DMA and TIM3

    TIM_DMACmd(TIM4, TIM_DMA_Update, ENABLE);

 /* TIM3 enable counter */

 TIM_Cmd(TIM4, ENABLE);

     // turning on TIM3 and PWM outputs

    TIM_CtrlPWMOutputs(TIM4, ENABLE);       

}