STM32G071 : TIMER (TIM6) Immediate Update of Reload Value (ARR)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 3:36 AM
Hi,
I am using STM32G071RB MCU 64-PIN TQFP and using Timer TIM6.
The ARR Register in not updated Immediate and It updated on Next Transistion.
Please understand below situation .
1) I have set below in STMCube.
2) As as Per calculation.
3) When I write ARR = 10 and after ARR = 90. .
a) The Timer first generate delay according 90.
b) Then according to ARR = 10.
I am Reload as below function.
void TimerReload(Reload Value)
{
TIM6->PSC = 6350 ;
TIM6->ARR = ReloadValue ;
HAL_TIM_Base_Start_IT(&htim6) ;
}
Is my Timer reloading method is correct or not ?
Anybody please reply..
Thanks in advance..
--
Karan
Solved! Go to Solution.
- Labels:
-
STM32CubeMX
-
STM32G0 Series
-
TIM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 6:34 PM
Clock in RCC has to be enabled as the very first thing.​
​
​Also read http://www.efton.sk/STM32/gotcha/g42.html
​
JW​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 3:49 AM
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 4:19 AM
Hi @Community member​
Thanks for update.. Please check my edited Post #1 and reply if possible.
--
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 4:29 AM
I don't use Cube. Who knows what those functions do now, and what will they do in the next version of Cube.
Timers are simple, read the TIM chapter in manual and use registers.
Preload of TIMx_ARR is controlled by TIMx_CR1.ARPE, but note, that TIMx_PSC is unconditionally preloaded, if you want to get it active immediately you have to force an Update event, usually by setting TIMx_EGR.UG.
Most of the time you want the preload to be active.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 5:09 AM
Hi,
Thanks Again for Update.
#define TIM_CR1_ARPE_Pos (7U)
#define TIM_CR1_ARPE_Msk (0x1UL << TIM_CR1_ARPE_Pos) /*!< 0x00000080 */
#define TIM_CR1_ARPE TIM_CR1_ARPE_Msk /*!<Auto-reload preload enable
#define TIM_EGR_UG_Pos (0U)
#define TIM_EGR_UG_Msk (0x1UL << TIM_EGR_UG_Pos) /*!< 0x00000001 */
#define TIM_EGR_UG TIM_EGR_UG_Msk /*!<Update Generation */
Do you mean like this ?
void TimerReload(Reload Value)
{
TIM6->PSC = 6350 ;
TIM6->CR1 |= TIM_CR1_ARPE ;
TIM6->ARR = ReloadValue ;
TIM6->EGR |= TIM_EGR_UG ;
HAL_TIM_Base_Start_IT(&htim6) ;
}
Or Anything..I am doing something wrong.
--
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 12:14 PM
Hi @waclawek.jan (Community Member)​
Is this is right way to update Timer Register Immdiatley without STMCubeCode ?
void TimerReload(unsigned int Reload Value)
{
TIM6->CR1 &= ~(TIM_CR1_CEN); // Disable the Counting First
RCC->APBENR1 |= (1u << 4 ); // ENABLE TIM6 CLOCK
TIM6->PSC = 6350 ; // Set Prescaler
TIM6->CR1 |= TIM_CR1_ARPE ; // Auto-reload preload enable
TIM6->ARR = ReloadValue ; // Auto-reload register
TIM6->CNT = 0 ; // Counter register
TIM6->EGR |= TIM_EGR_UG ; // Update Event Generation
TIM6->DIER |= TIM_DIER_UIE; // Enable the Update Interrupt
TIM6->CR1 |= TIM_CR1_CEN; // Enable the Counting
}
Thanks In Advance..
--
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-18 6:34 PM
Clock in RCC has to be enabled as the very first thing.​
​
​Also read http://www.efton.sk/STM32/gotcha/g42.html
​
JW​
