cancel
Showing results for 
Search instead for 
Did you mean: 

How to get TIM16 to run from LSI on STM32G030F6P6?

RLour.1
Associate II

Try as I might in the STM32CubeMX I can't get TIM16 to use the LSI as the input.

MX_TIM16_Init();
  /* USER CODE BEGIN 2 */
  // Start timer
  HAL_SuspendTick();
  HAL_TIMEx_TISelection(&htim16, 1, TIM_CHANNEL_1);
  HAL_TIM_Base_Start_IT(&htim16);

The call to HAL_TIMEx_TISelection() ends up performing this write to the TISEL register of TIM16

MODIFY_REG(htim->Instance->TISEL, TIM_TISEL_TI1SEL, TISelection);

Bit definitions

0693W00000NpWRIQA3.png0693W00000NpWR8QAN.png 

Here is my STM32CubeMX setup.

0693W00000NpWQjQAN.pngI am expecting roughly 1/2 Hz interrupt with a 16000 setting. Instead, I am getting 1mSec.

Any help is appreciated.

Thanks

4 REPLIES 4

Read out and check/post TIM16 registers content.

JW

RLour.1
Associate II

I am trying to clock TIM16 with LSI according to page 132 of the following manual.

From 132

0693W00000NpY9BQAV.png 

I am referencing this document0693W00000NpY3cQAF.png0693W00000NpY1gQAF.png 

Name : tmr16
	Details:0x40014400
	Default:0x40014400
	Decimal:1073824768
	Hex:0x40014400
	Binary:1000000000000010100010000000000
	Octal:010000242000
 
Name : CR1
	Details:129
	Default:129
	Decimal:129
	Hex:0x81
	Binary:10000001
	Octal:0201
 
Name : CR2
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : DIER
	Details:1
	Default:1
	Decimal:1
	Hex:0x1
	Binary:1
	Octal:01
 
Name : SMCR
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : SR
	Details:3
	Default:3
	Decimal:3
	Hex:0x3
	Binary:11
	Octal:03
 
Name : EGR
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCMR1
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCMR2
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CNT
	Details:7950
	Default:11776
	Decimal:11776
	Hex:0x2e00
	Binary:10111000000000
	Octal:027000
 
Name : CCER
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : RCR
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : ARR
	Details:16000
	Default:16000
	Decimal:16000
	Hex:0x3e80
	Binary:11111010000000
	Octal:037200
 
Name : PSC
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCR1
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCR2
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCR4
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCR3
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : DCR
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : DMAR
	Details:129
	Default:129
	Decimal:129
	Hex:0x81
	Binary:10000001
	Octal:0201
 
Name : CCR5
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCR6
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : CCMR3
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : AF1
	Details:1
	Default:1
	Decimal:1
	Hex:0x1
	Binary:1
	Octal:01
 
Name : BDTR
	Details:8192
	Default:8192
	Decimal:8192
	Hex:0x2000
	Binary:10000000000000
	Octal:020000
 
Name : OR1
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : AF2
	Details:0
	Default:0
	Decimal:0
	Hex:0x0
	Binary:0
	Octal:0
 
Name : TISEL
	Details:1
	Default:1
	Decimal:1
	Hex:0x1
	Binary:1
	Octal:01

RLour.1
Associate II

I think I found my own answers. None of the timers can be clocked by the LSI. You can measure the LSI by using it as a gate for the counter, but not to drive the counter. Drat.

Indeed, TIM16 does not have the slave-mode controller so you can't use TIM16_CH1 as source for external clock mode.

The TIM15/16/17 chapter is confusing in that TIM15 has a different structure than TIM16 and TIM17 and I've looked at the wrong diagram (in RM444 the TIM15 block diagram is placed into the TIM16/TIM17 main features chapter...)

You still can use LSI as input clock to LPTIM or RTC.

Please select your post as Best so that thread is marked as solved.

JW