cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Template BLE and LPM

oga
Associate III

I everyone ,
I'm working on a STM32WB35

I've build a small custom server app with just a simple batt level service it works and advertise perfectly if I don't enable LPM as soon as I enable LPM it don't advertise anymore

it looks as if CPU2 and RF are down too as default BLE app disable OFF lpm mode it goes only in STOP LPR mode

on my custom pcb I have no LSE so I rely on HSE when running and MSI or HSI when in stop or off

oga_0-1712761048851.png

oga_1-1712761081244.png

when  comparing with BLE HeartSensor reference exemple I dont understand how it keeps advertising when  in STOP mode

my main concern is on BLE HeartSensor exemple when going in stop mode it calls

 

 

 

static void EnterLowPower(void)
{
  /**
   * This function is called from CRITICAL SECTION
   */
  while(LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID));
  if (! LL_HSEM_1StepLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID))
  {
    if(LL_PWR_IsActiveFlag_C2DS() || LL_PWR_IsActiveFlag_C2SB())
    {
      /* Release ENTRY_STOP_MODE semaphore */
      LL_HSEM_ReleaseLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID, 0);
      Switch_On_HSI();
      __HAL_FLASH_SET_LATENCY(FLASH_LATENCY_0);
    }
  }
  else
  {
    Switch_On_HSI();
    __HAL_FLASH_SET_LATENCY(FLASH_LATENCY_0);
  }
  /* Release RCC semaphore */
  LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0);
  return;
}

 

 

 

but when switching to HSI sysclk should fall at 16Khz and CPU2 clock too

oga_0-1712829155087.png

may be it explain why I can't get advertising when CM4 is STOP in my custom APP but it dont explain why it works on HEARTSensor exemple

thank's for any help or info or idea !!

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Can you add more details about your confusion so i can clarify more about it.

Best Regards.

STTwo-32

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
STTwo-32
ST Employee

Hello @oga 

Could you try the following steps:

  • Ensure that the BLE stack is initialized.

  • Use the LPM manager.

  • Configure the M4 core to enter STOP2 mode.

  • Handle wake-up events.

  • Refer to example code.

  • Consider the impact of interrupts.

  • Review the power mode transitions.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello STTow-32 

thank's for your reply

  • Ensure that the BLE stack is initialized.

yes it is in fact if I don't let go in stop mode every thing is working

  • Use the LPM manager.

yes that's what I'm doing I've put some debug tags in enter/exit lpm modes functions

  • Configure the M4 core to enter STOP2 mode.

I've try all modes Stop 0/1&2

  • Handle wake-up events.

I should be waked up by RF event

  • Refer to example code.

I have and it looks pretty straight forward

  • Consider the impact of interrupts.

I'm trying to fall into RF interrupt but

My best bet is that : due to pcb size I've no LSE quartz that impose to use HSE/1024 for RF clock

but HSE is not available in STOP2 

 

when looking in ref manual I have 2 interrogations


The functionality in Stop mode (including wakeup) is supported only when the clock is
LSE. When HSE/1024 is selected as RF system wakeup source HSEON bit must be
set by the application.
 The RF system clock is derived (selected by hardware) from one of the two following
sources:
– HSI16 clock
– HSE clock
The functionality in Stop mode is supported only when the clock is HSI16 is selected as
wakeup clock by STOPWUCK.

I dont understand well (sorry I'm not native english speaker) it says that RF wake up in stop mode is only working when clock is LSE and just behind it looks to say that it can be HSE/1024 or HSI16

and when looking into datasheet we can read on p36/37


HSE (32 MHz) automatically used when RF activity is needed by the RF subsystem

I feel a bit confused

 

Can you add more details about your confusion so i can clarify more about it.

Best Regards.

STTwo-32

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

sorry for late reply

I've solved this issue regarding LSE vs HSE for RF wakeup

my confusion was is it possible to be waked up by RF if shutting down HSE or setting RF WKUP on LSE

but know I have another issue regarding LPM & BLE (I will open a new topic)