2017-07-14 01:45 AM
Hi. I'm trying to count impulses on LPTIM2 in STOP2 mode.
Enabe clocks:
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM2_CLKSOURCE_LSE);
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPTIM2);Configuring PC0 pin:
LL_GPIO_SetPinMode(GPIOC, LL_GPIO_PIN_0, LL_GPIO_MODE_ALTERNATE); LL_GPIO_SetAFPin(GPIOC, LL_GPIO_PIN_0, LL_GPIO_AF_14); LL_GPIO_SetPinSpeed(GPIOC, LL_GPIO_PIN_0, LL_GPIO_SPEED_FAST); LL_GPIO_SetPinOutputType(GPIOC, LL_GPIO_PIN_0, LL_GPIO_OUTPUT_PUSHPULL); LL_GPIO_SetPinPull(GPIOC, LL_GPIO_PIN_0, LL_GPIO_PULL_NO);Configuring LPTIM2:
LL_LPTIM_SetAutoReload(LPTIM2, 0xFFFF);LL_LPTIM_SetClockSource(LPTIM2, LL_LPTIM_CLK_SOURCE_EXTERNAL);
LL_LPTIM_SetPrescaler(LPTIM2, LL_LPTIM_PRESCALER_DIV1); LL_LPTIM_SetPolarity(LPTIM2, LL_LPTIM_OUTPUT_POLARITY_REGULAR); LL_LPTIM_SetUpdateMode(LPTIM2, LL_LPTIM_UPDATE_MODE_IMMEDIATE); LL_LPTIM_SetCounterMode(LPTIM2, LL_LPTIM_COUNTER_MODE_EXTERNAL); LL_LPTIM_ConfigClock(LPTIM2, LL_LPTIM_CLK_FILTER_NONE, LL_LPTIM_CLK_POLARITY_RISING); LL_LPTIM_TrigSw(LPTIM2); LL_LPTIM_ConfigTrigger(LPTIM2, LL_LPTIM_TRIG_SOURCE_GPIO, LL_LPTIM_TRIG_FILTER_NONE, LL_LPTIM_TRIG_POLARITY_RISING); LL_LPTIM_SetInput1Src(LPTIM2, LL_LPTIM_INPUT1_SRC_GPIO);LL_LPTIM_Enable(LPTIM2);
and then:
LL_LPTIM_StartCounter(LPTIM2, LL_LPTIM_OPERATING_MODE_ONESHOT);Configuration is based on what STMCubeMX generated. I connected PC0 with function generator 3.3V, 50Hz (signal is valid, checked on osciloscope; for test, later I'll need up to 16kHz, LSE is standard clock quartz 32.768 kHz).
I tried with different configurations, but counter is always 0.
2017-07-14 06:16 AM
Hello
Konieczny.Jakub
,There is no STM32L487 ! I think you mean 485 or 486 ?
Regards
Imen