2020-12-08 09:53 AM
I use these fonction to enable all three channels:
HAL_TIM_OnePulse_Start(&htim3, TIM_CHANNEL_1);
HAL_TIM_OnePulse_Start(&htim3, TIM_CHANNEL_2);
HAL_TIM_OnePulse_Start(&htim3, TIM_CHANNEL_3);
it have to insert this to enable ch3 but just for the channel 3.
htim3.Instance->CCMR2 = TIM_CCMR2_OC3PE| (7<<TIM_CCMR2_OC3M_Pos);
htim3.Instance->CCER |= TIM_CCER_CC3E
I'm asking this question because I'm not sure if there is an issue with HAL or it's just me.
Best regards,
2020-12-08 10:04 AM
What chip?
2020-12-08 10:24 AM
Stm32f103rb, the nucleo board
2020-12-08 10:31 AM
TIM_CHANNEL_3 is not a valid argument to HAL_TIM_OnePulse_Start.
/**
* @brief Starts the TIM One Pulse signal generation.
* @param htim TIM One Pulse handle
* @param OutputChannel TIM Channels to be enabled
* This parameter can be one of the following values:
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
* @retval HAL status
*/
HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
Seems like it should be included, but maybe there's a reason for it being missing.
2020-12-08 10:56 AM
This function (and the related "surroundings" of it) is aimed at one particular application, where one channel serves as a hardware trigger, and the other as output.
/* Enable the Capture compare and the Input Capture channels
(in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
No need to enable the counter, it's enabled automatically by hardware
(the counter starts in response to a stimulus and generate a pulse */
See also the related examples:
Configuration of TIM5 in One Pulse Mode
===================================================
- The external signal is connected to TIM5_CH2 pin (PA.01),
and a rising edge on this input is used to trigger the Timer.
- The One Pulse signal is output on TIM5_CH1 (PA.00).
The delay value is fixed to:
- Delay = CCR1/TIM5 counter clock
= 16383 / 18000000 [sec]
The pulse value is fixed to :
- Pulse value = (TIM_Period - TIM_Pulse)/TIM5 counter clock
= (65535 - 16383) / 18000000 [sec]
The one pulse waveform can be displayed using an oscilloscope and it looks
like this.
____
| |
CH2 _________________________| |__________________________________________
___________________________
| |
CH1 ______________________________________| |_____
<---Delay----><------Pulse--------------->
In other words, this is implementation of a one-shot flip-flop with delay.
This of course is only one very specific application of the OPM in timer. That's Cube/HAL for you.
Oh, and it's an excellent illustration of Cube/HAL documentation, too.
JW
2020-12-08 11:31 AM
ok, thank you.
I may have to adapt this function.
2020-12-13 08:11 AM
Hi,
I finally get my timer working as I wish. I went directly programming the register. In my case, I use the timer 1 to trigger the timer 3 (one pulse mode) on the microcontroler as i needed so extra feature from the timer 1 (the repetition counter).
Apparently, if an internal trigger is selected as the trigger input, it is not needed to configure a channel as an input.
I am a bit concern now, will I still be able to use other hal libraries on my project ?
R.
2020-12-13 10:25 AM
> will I still be able to use other hal libraries on my project ?
Probably yes, if they are not using the given timer(s). I don't use Cube/HAL.
JW