2016-12-23 10:30 AM
Hello
I'm supposed to generate pulse train with stm32f10x and cmsis library.
TIM_TimeBaseInitTypeDef TIMST;
TIMST.TIM_Prescaler=72;
TIMST.TIM_Period=1000;
TIMST.TIM_ClockDivision=TIM_CKD_DIV1;
TIMST.TIM_CounterMode= TIM_CounterMode_Up ;
TIM_TimeBaseInit(TIM2, &TIMST);
TIM_OCInitTypeDef TIMCRC;
TIMCRC.TIM_OCMode=TIM_OCMode_Toggle;
TIMCRC.TIM_OCIdleState=TIM_OCIdleState_Reset; TIMCRC.TIM_OCNIdleState=TIM_OCNPolarity_Low; TIMCRC.TIM_OCPolarity=TIM_OCPolarity_High; TIMCRC.TIM_OCNPolarity=TIM_OCPolarity_Low; TIMCRC.TIM_OutputNState=TIM_OutputNState_Disable; TIMCRC.TIM_OutputState=TIM_OutputNState_Enable; TIMCRC.TIM_Pulse=But I don't know how I can define Pulse variable value for specific output frequency.(Is this code correct? or I did some mistake? )
#stm32f10x #timer2016-12-26 08:46 AM
Hi
Mohamadi.Parisa
,Please precise what do you expect exactly as result?
Did you tried this code and it doesn't match what you need?
I recommend you to refer to theGeneral-purpose timer cookbook (
) : it explains various use cases related to timers and can be helpful for you to implement your own case.-Amel-
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2016-12-26 09:14 AM
Thanks for your response.
Actually I want to create a square pulse (frequency <100khz) with Stm32f10x and timer output compare mode.I have seen different codes that they use PWM mode but I want to learn how can work in output compare mode with timers?
So I need to know how can I define Prescaler, Periode and Pulse variables for an specific output frequency? and where can I find simple code in output compare mode?
I haven't read time cookbook yet but maybe I will find my answer.