cancel
Showing results for 
Search instead for 
Did you mean: 

LPTIM Counter in Stop2 Mode

Jeongyoon Moon
Associate
Posted on July 05, 2018 at 10:15

Hi, everyone. I'm implementing a shock counter using STM32L476 LPTIM counter & LIS2DH12 click interrupt.

I connect LIS2DH12 INT2 pin to LPTIM_IN1 to implement shock counter. ( I expect increment of LPTIM counter when shock(click interrupt) occurs. )

My implementation seems to be working fine when the MCU is awake. (i.e. counter increases when I apply shock) However, when the MCU goes to STOP2 Mode, counter value doesn't change even if I apply shock.  

I check this by

1) read and check counter value

2) MCU goes to STOP2 Mode

3) Apply shock

4) Wake MCU up using GPIO interrupt, and do 1)

Are there any suggestions to solve this problem? Do I need to configure something to enable LPTIM in STOP2 Mode?

Below are parameters what I used.

-------------------------------------------------------------------------------------------------------------------------------------------

In RCC configuration,

PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_PCLK;

LPTIM configuration:

static void MX_LPTIM1_Init(void)

{

hlptim1.Instance = LPTIM1;

hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_ULPTIM;

hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;

hlptim1.Init.UltraLowPowerClock.Polarity = LPTIM_CLOCKPOLARITY_RISING;

hlptim1.Init.UltraLowPowerClock.SampleTime = LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION;

hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;

hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH;

hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;

hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_EXTERNAL;

hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO;

hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO;

if (HAL_LPTIM_Init(&hlptim1) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

}

#stm32l476-stop2-mode #stm32l476-lptim-counter #stm32l476-lptim
1 REPLY 1

Sorry, bumping old zombie unanswered threads off my feed

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..