2018-01-30 06:52 AM
I am trying to understand how to configure a timer in one pulse mode, using the STM32F100VLDISCOVERY board. I have used STM32CUBEMX to configure the blue button (PA0) as TIM2_CH1 ('Channel 1 input capture direct mode'), and PA1 as TIM2_CH2 '(Channel2 PWM Generation'). (STM32CUBEMX project attached).
I added a single line to the project, just after the line that says: 'MX_TIM2_Init();' :
HAL_TIM_OnePulse_Start(&htim2, TIM_CHANNEL_2);
When I press the Blue Button, I see the 'CC1IF' bit (SR register) momentarily toggle. But I don't see a pulse on PA1.
I imagine I'm still missing a line of code or two, advice/assistance is greatly appreciated.
#one-pulse-mode #stm32f100vldiscovery2018-02-01 10:27 AM
If the timer's run (given by ARR and PSC) is to be longer than the bouncing, then it's not needed - triggering an already running timer does nothing.
JW
2018-02-01 10:34 AM
And if he wanted the one-shot on button release he would need to filter/debounce for the press noise, no matter the period of the timer, unless the bounce is less than one sample, in which case ... he didn't need the filter.
2018-02-01 10:44 AM
Indeed - the same applies for release noise in case of shooting the one on button press.
One more remark - the value selected in that box is apparently not the number of samples taken, see TIMx_CCMR1.IC1F description in TIM chapter of RM.
JW
2018-02-05 03:22 PM
Thanks everyone. Most things are easy, once you know the answer
Below is the STM32CubeMX config (for 2 timers, I got bold), and the info for Timer 2. The timers should be started with this code:
HAL_TIM_OnePulse_Start(&htim1, TIM_CHANNEL_1); HAL_TIM_OnePulse_Start(&htim2, TIM_CHANNEL_2);I would now like to start Timer 2 from Timer 1 being started instead of the button (I have wired the button to Timer 1 as well). Working to try to figure out that next.
2018-02-06 01:31 AM
In TIM1 once set to trigger from the input (button), set TIM1_CR2.MMS to 0b001, so that enable signal is used as TRGO.
In TIM2, set TIM2_SMCR.TS to that Internal Trigger which is coming from TIM1, see TIM2 row of table at TIMx_SMCR description in RM. Then set TIM2_SMCR.SMS to 0b110 for Trigger mode.
That's all.
JW