How make for Stm32F407G-DISC1 with Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-06-25 7:13 AM - last edited on ‎2023-09-01 9:44 AM by Amel NASRI
I try make"design system that sets outputPin (should be digital gpio output ) high for 0.25 secs,and low for 0.25 secs."
and i use GPIOA_PIN4(input) and GPIOB_PIN0(output), I'm new to stm32, I'm having trouble with the timer.
I try use tim, how can I do it (high for 0.25 secs,and low for 0.25 secs.)
- Labels:
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-06-25 7:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-06-27 2:19 AM
Hello @Pogomo and welcome to the Community :),
Besides, the "General-purpose timer cookbook for STM32 microcontrollers" shared by @Pavel A. , I advise you to get inspired from the available TIM_TimeBase example in the STM32CubeF4 MCU package. This example may help you to configure the timer by following the instructions in the readme file.
I hope this help you!
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-06-30 9:40 AM
for something like this, I would:
FOREVER {
HAL_Delay(250);
HAL_GPIO_WritePin(GPIO_Output_Port, GPIO_Output_Pin, GPIO_PIN_SET);
HAL_Delay(250);
HAL_GPIO_WritePin(GPIO_Output_Port, GPIO_Output_Pin, GPIO_PIN_RESET);
}
Unless you really need to use a TIM timer. You already have the SYSTICK timer active anyway, you might as well get some use out of it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-06-30 9:53 AM
Using a TIM timer, on a 407VGT, pin PB0 can be TIM1 channel 2N, TIM3 channel 3, or TIM8 channel 2N. I'd go with TIM3 channel 3 so you don't have to worry about the weirdness of the inverted output channels (ending in N).
Set up TIM3 to generate a 50% PWM with a frequency of 2Hz. This will involve taking your base processor frequency, figure out what the frequency of the APB1 timer bus is (TIM3 is on APB1), then configure TIM3 with an internal clock source, set the prescaler and counter period to generate 2Hz, channel 3 to generate PWM on CH3, set the Pulse count to be 1/2 of what the counter period is, then start the timer in PWM mode.
This is a very coarse overview, you'll have to figure out the details for your board and what the appropriate code sequence is to set up the timer. I use CubeIDE and HAL, you may want to stuff values into registers (like an animal), but the code will vary depending on your board and code proclivities.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-06-30 10:17 AM
And on start ask self , how precise 0,25 sec you require.
