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-01-30 07:18 AM
Read out and check/post the content of relevant GPIO and TIM registers.
JW
2018-01-30 08:34 AM
2018-01-30 09:17 AM
In timer, you want to have SMCR.TS set to TI1FP1 and SMCR.SMS set to Trigger Mode - thus pressing the blue button starts the timer. You also want to have a nonzero CCR2 otherwise your output pulse length is zero.
You can try to set all this in the debugger, you don't need to write any code to try.
I don't Cube so I don't know how to click this in CubeMX nor write in Cube's terms.
I did not check GPIO - sorry, I don't use 'F1xx and their GPIO is different from the others.
JW
2018-01-30 09:57 AM
Thanks for the help so far! So in STM32CUBEMX I can set Slave Mode to ''Trigger Mode''. But TI1FP1 is not an available choice in Trigger Source (it is grayed out, see screenshot).
2018-02-01 07:24 AM
Bump
2018-02-01 08:41 AM
As I've said, I don't and won't Cube/CubeMX so can't help with the clicking, sorry.
JW
2018-02-01 09:07 AM
You have channel1 set as input. This locks using TI1FP1 as a trigger.
Set channel1 to disabled.
Then you will be able to choose TI1FP1 as the trigger.
2018-02-01 09:10 AM
What you are trying to do is quite easy if you simply follow the datasheet. Set up the time base, set up the output compare module, but put it in freeze:OCiM = 0b000.
Once a button press is detected, put the OCiM in one pulse mode. And optionally reset the counter.
One thing through, a button press is a dirty source so some form of debouncing would be desirable.
2018-02-01 09:17 AM
If you are using a mechanical switch,
apply the Trigger Filter = 15 (most filtering or debounce)
filter is the number of trigger samples the trigger signal has be stable before the input signal to the timer changes.
see RM;