2018-08-01 04:27 AM
Hello,
I am working on a project involving the STM32L433RCT6 microcontroller. The microcontroller has to go in low power and then returns in run mode after a certain time.
The mode chosen is the "standby mode" with RTC and SRAM 2 memory active to maintain data. The wake up is given by the internal RTC every 20 seconds. I have read that all devices should be disabled in this condition.
The peripherals or modules used are:
- ADC (channel 15).
- I2C (channel 1).
- USART (channels 1 and 3).
- SPI (canaili 2).
- CRC.
- CANBUS (channel 1).
- TIMER (number 6).
I am using a PCB with only the microcontroller mounted to which I connected the power supply and a ST-LINK V2 for debugging. No other devices are mounted.
The absorption measured by the tester is equal to 650uA with connected ST Link, 360uA with ST Link disconnected. It should be 0.43uA (about 1000 times less).
In that mode the peripherals should be turned off, but I also tried to turn off the corresponding RCC timer, without success.
Do you have any advice?
Below is the code I wrote to go to standby using the ST libraries.
void StandbyRTCBKPSRAMMode_Measure ( void )
{
/*## Configure the Wake up timer ###########################################*/
/* RTC Wakeup Interrupt Generation:
Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI))
Wakeup Time = Wakeup Time Base * WakeUpCounter
= (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter
==> WakeUpCounter = Wakeup Time / Wakeup Time Base
EXAMPLE:
To configure the wake up timer to 20s the WakeUpCounter is set to 0xA017:
RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16
Wakeup Time Base = 16 /(~32.768KHz) = ~0,488 ms
Wakeup Time = ~20s = 0,488ms * WakeUpCounter
==> WakeUpCounter = ~20s/0,488ms = 40983 = 0xA017
This section is already present in the init functions.
*/
/* Disable Wake-up timer */
if ( HAL_RTCEx_DeactivateWakeUpTimer(&hrtc) != HAL_OK )
{
/* Exit immediately */
return;
}
/*#### Clear all related wakeup flags ######################################*/
/* Disable all used wakeup sources: WKUP pin */
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN1 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN2 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN3 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN4 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN5 );
/* Clear PWR wake up Flag */
__HAL_PWR_CLEAR_FLAG( PWR_FLAG_WU );
/* Clear RTC Wake Up timer Flag */
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG( &hrtc, RTC_FLAG_WUTF );
/**
* @brief Enable SRAM2 content retention in Standby mode.
* @note When RRS bit is set, SRAM2 is powered by the low-power regulator in
* Standby mode and its content is kept.
*/
HAL_PWREx_EnableSRAM2ContentRetention( );
/** Disable peripheral clocks
*/
HAL_ADC_DeInit(&hadc1);
HAL_CAN_DeInit(&hcan1);
HAL_CRC_DeInit(&hcrc);
HAL_I2C_DeInit(&hi2c1);
HAL_SPI_DeInit(&hspi2);
HAL_TIM_Base_DeInit(&htim6);
HAL_TSC_DeInit(&htsc);
HAL_UART_DeInit(&huart1);
HAL_UART_DeInit(&huart3);
/** Setting the pull-up - pull-down registers
*/
HAL_PWREx_EnableGPIOPullUp ( PWR_GPIO_A, GPIO_PIN_3 );
HAL_PWREx_EnableGPIOPullUp ( PWR_GPIO_C, GPIO_PIN_12 );
HAL_PWREx_EnableGPIOPullDown ( PWR_GPIO_A, GPIO_PIN_1);
HAL_PWREx_EnableGPIOPullDown ( PWR_GPIO_A, GPIO_PIN_5 );
HAL_PWREx_EnableGPIOPullDown ( PWR_GPIO_B, GPIO_PIN_15 );
HAL_PWREx_EnablePullUpPullDownConfig();
/** Re-Enable the WakeUp
*/
if ( HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 20, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK )
{
_Error_Handler(__FILE__, __LINE__);
}
/*#### Enter the Standby mode ##############################################*/
/* Request to enter STANDBY mode */
HAL_PWR_EnterSTANDBYMode();
}
Thanks in advance.
best regards,
2018-08-01 06:58 AM
I update the topic: I remove the ST LINK V2 and the correspondent VDD - GND signal and the current absorption reduces to 102uA. Not enough, because I want to reach less than 1uA (as datasheet says).
2018-08-01 08:49 AM
another thing: I use the System Workbench for STM32 in debug mode.