2011-12-26 09:42 AM
I want to generate a signal of frequency 250 kHz with a duty cycle of 50%. after 100 cycle the output has to be low continuously until next fifty cycle and again the trend is to be continued.
Can anyone suggest me how can i implement with the PWM Mode counter implementation. It should be taken into consideration that during the gap of fifty cycle the interrupt service routine has to be free (i.e. ISR of the timer should leave at the end of 100th cycle and come back after fifty cycle and do the same for next 100 cycle). For the startup (the prescalers could be as follows with system freq 72 Mhz): TIM_TimeBaseStructure.TIM_Period = 287; TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); /* PWM1 Mode configuration: Channel2 */ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = 144; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; TIM_OC2Init(TIM2, &TIM_OCInitStructure); TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); TIM_OC2PreloadConfig(TIM2, TIM_OCPreload_Enable); TIM_ARRPreloadConfig(TIM2, ENABLE); /* TIM2 enable counter */ TIM_Cmd(TIM2, ENABLE); I would be glad if someone could help me.2011-12-27 05:38 AM
You could use a synchronous time base that is 50 (or 100) times slower to pull the pulse width in/out, I'm not sure from you description what your output should look like (250 KHz has 50/50 duty, but is then off/on for what periods? 200 us or 400 us).
If you don't want to have any interrupts you could AND two time bases externally. If this is a commercial project, and you're looking to out-source coding work, ST does maintain a list of contractors.2011-12-27 02:05 PM
My requirement is a pulse of duration 4 us (not 400 us) and half of its duration to be 2 us (not 200 us). So PWM=50%, frequency = 250 Khz. High time: 2us, Low time: 2us.
Also at each first cycle i need to generate a single pulse(just one pulse) of duration of 4 us (only high). The work is fully academic and not commercial but the work or the output should work with real time users. In short, i am learning but not earning. From: clive1Posted: Tuesday, December 27, 2011 2:38 PMSubject: PWM mode output caseYou could use a synchronous time base that is 50 (or 100) times slower to pull the pulse width in/out, I'm not sure from you description what your output should look like (250 KHz has 50/50 duty, but is then off/on for what periods? 200 us or 400 us).
If you don't want to have any interrupts you could AND two time bases externally. If this is a commercial project, and you're looking to out-source coding work, ST does maintain a list of contractors.