Generate Single pulse using timer using HAL / CubeMx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-17 1:36 AM
I have been reading reading anything i could find on Timers, but I'm still confused about the setup in CubeMx.
I just want to trigger a timer in software, that generates a SINGLE pulse with a set width (and if possible after a set dely) on a pin, but the CubeMx configuration is incredibly badly documented and pretty confusing, if you don't already know what you are doing.
can someone please point me in the right direction?
Also please don't post a bunch of register setups and then say "I don't use CubeMx", that's not what i am asking, and I have seen it on so many forum posts.
Solved! Go to Solution.
- Labels:
-
STM32CubeMX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-17 3:30 AM
Ok, I have found the answer myself.
Here is the setup: (every setting i don't mention is either disabled or in it's standard state)
- Clock Source: Internal clock
- Channelx PWM Generation Channelx (if set to Output compare, it won't reset after the timer is done counting)
- One Pulse Mode Enabled
under PWM Generation Channelx:
- Pulse gives the width of the pulse
Polarity and Pulse Width:
The combination of CounterMode, PWM Mode and CH Polarity gives you different output polarities delay.
in Code:
execute this onece:
HAL_TIM_OnePulse_Start(&htimX, TIM_CHANNEL_X);
To trigger the pulse just execute this, whenever you need a pulse to be generated:
TIMx->CR1 |= TIM_CR1_CEN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-17 2:10 AM
Are you referring to the One pulse mode of stm timers?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-17 3:30 AM
Ok, I have found the answer myself.
Here is the setup: (every setting i don't mention is either disabled or in it's standard state)
- Clock Source: Internal clock
- Channelx PWM Generation Channelx (if set to Output compare, it won't reset after the timer is done counting)
- One Pulse Mode Enabled
under PWM Generation Channelx:
- Pulse gives the width of the pulse
Polarity and Pulse Width:
The combination of CounterMode, PWM Mode and CH Polarity gives you different output polarities delay.
in Code:
execute this onece:
HAL_TIM_OnePulse_Start(&htimX, TIM_CHANNEL_X);
To trigger the pulse just execute this, whenever you need a pulse to be generated:
TIMx->CR1 |= TIM_CR1_CEN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-05 12:43 PM
Instead of TIMx->CR1 |= TIM_CR1_CEN; you can simply do this:
__HAL_TIM_ENABLE(&htimX);
(just for clarity of intent of the code)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-09 8:23 AM
Hi All,
This question has been routed to our Online Support Center for direct support and we will be taking this question directly from there. This question will be taken offline.
Regards,
Jake
ST Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-10 1:29 PM
First, the issue was solved and there is nothing to "support" here. Second, it was 2 years ago...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-10 2:32 PM
@Jacob WOODRUFF​ ,
Besides, as Piranha said above, there is nothing to"support" here, are you aware of the fact that this is a public forum? Taking a question "offline" is censoring it, is it really what ST wants to do here?
JW
@Lina DABASINSKAITE​
