2022-05-06 05:53 PM
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
Here is my STM32CubeMX setup.
I am expecting roughly 1/2 Hz interrupt with a 16000 setting. Instead, I am getting 1mSec.
Any help is appreciated.
Thanks
2022-05-07 01:12 AM
Read out and check/post TIM16 registers content.
JW
2022-05-07 07:36 AM
I am trying to clock TIM16 with LSI according to page 132 of the following manual.
From 132
I am referencing this document
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
2022-05-07 12:03 PM
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.
2022-05-08 12:03 AM
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