2019-11-25 06:38 AM
Hello all
I ajust trying to measure the curreent of my circuit in standby mode
i wrote a small code that wake up the mcu from RTC alarm A ad then go in standbye mode
when i download the program the program works ok , it wakeup every 10 seconds from RTC alarm and go stanby mode but the current in standbye mode is high about 1,5mA
but if switch the battery off and again ON ; then the software works ok and wakes the MCU evert 10 seconds from RTC but now the standby in 4uA which is ok .
I dont understand what is wrong the circuit is just simple one MCU + LDO ( 4uA) .
here is the code ,
thank you inadvanced
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
// MX_USB_OTG_FS_USB_Init();
/* USER CODE BEGIN 2 */
rtc_alarm_test();
if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
/* Clear Standby flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET);
HAL_Delay(5);
//
HAL_Delay(5000);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_RESET);
/* Enable GPIOs clock */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
/* Set all GPIO in analog state to reduce power consumption, */
/* except GPIOC to keep user button interrupt enabled */
/* Note: Debug using ST-Link is not possible during the execution of this */
/* example because communication between ST-link and the device */
/* under test is done through UART. All GPIO pins are disabled (set */
/* to analog input mode) including UART I/O pins. */
GPIO_InitStructure.Pin = GPIO_PIN_All;
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
GPIO_InitStructure.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOF, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);
/* Disable GPIOs clock */
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOD_CLK_DISABLE();
__HAL_RCC_GPIOE_CLK_DISABLE();
__HAL_RCC_GPIOF_CLK_DISABLE();
__HAL_RCC_GPIOG_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
__HAL_RCC_PWR_CLK_ENABLE() ;
/* wait 100 ms */
HAL_Delay(100);
HAL_PWR_EnterSTANDBYMode();
while(1);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
2019-11-25 10:26 PM
Any help here please
2019-11-28 01:07 AM
Hello ; wait support here please ; i still could not make the MCU go to standby without remove power
2019-11-28 01:26 AM
There is no STML475, you probably meant STM32L475?
From RM0351:
Debug mode
By default, the debug connection is lost if the application puts the MCU in Stop 0, Stop1,
Stop 2, Standby or Shutdown mode while the debug features are used. This is due to the
fact that the Cortex ® -M4 core is no longer clocked.
However, by setting some configuration bits in the DBGMCU_CR register, the software can
be debugged even when using the low-power modes extensively. For more details, refer to
Section 48.16.1: Debug support for low-power modes.
This, of course, depends on your toolchain.
JW
PS Change your username to a normal nick.
2019-11-29 01:26 AM
Thank you WAclawek
My problem is not debug or debug in standbye mode
my problem: when i load the program to mcu the mcu does not go to standby mode. ; i need to turnoff power and turn on ; then in goes in standby mode
i shared in my previous post the code that i test
2019-12-05 05:53 AM
Any support here , please?