Question
Trigger TIM2 using a GPIO as external trigger
Hi,
on a STM32L451CE I try to make use of TIM2 timer. I want to start this timer on an external trigger event. From the device datasheet I know that the pin PA0 can be used with AF14 as a TIM2_ETR. However when I setup the timer it doesnt start counting, although I received a rising edge on that line. Can you help me why its not start counting?
Here are the relevant code parts I've written to enable the mechanism:
#define TIM2_CCMR1 (volatile uint32_t *) (TIM2_BASE + 0x18)
#define TIM2_CCER (volatile uint16_t *) (TIM2_BASE + 0x20)
#define TIM2_SMCR (volatile uint32_t *) (TIM2_BASE + 0x08)
void Init()
{
LL_GPIO_StructInit(&GPIO_InitStruct);
// Serializier BNE
GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_14;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
*TIM2_CCMR1 &= 0xFFFFFFFC;
*TIM2_CCMR1 |= 0x1;
*TIM2_CCER &= 0xFFFFFFFC;
*TIM2_CCER |= 0x2;
*TIM2_SMCR &= 0xFFFFFFF8;
*TIM2_SMCR |= 0x6;
*TIM2_SMCR &= 0xFFFFFF8F;
*TIM2_SMCR |= 0x50;
}What am I missing here?
Any help is appreciated, if you need additional info please let me know.
Thanks, Steve
