用STM32L4R5ZI开发板运行低功耗代码,让开发板进入待机模式,但程序在时钟初始化部分卡住了。重启开发板后,它会运行HAL_Init,但仍处于低功耗模式(运行时钟部分时电流约为600 uA,而非预期的10+ mA),并且会卡住(电流维持在2.3 mA左右)。拔掉USB线重新插上后,仍然处于相同状态(卡在2.3 mA)。
可能是以下原因之一:
我的代码有问题,导致开发板进入了无法退出的异常状态
我的预估有误,根据代码逻辑,这种行为是正常的
我的开发板有问题
HAL_Init没有按预期工作
我使用的是STM32CubeIDE V1.8.0和L4框架V1.17.2。目前我不知道该如何进一步排查问题,因为根本原因尚不明确。
int main(void)
{
/* 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 */
HAL_Delay(5000); // Added in case it's putting it in sleep mode when trying to program
/* I did try this code at one point, not sure if any of this could've broken something */
// /* Enable Power Clock */
// __HAL_RCC_PWR_CLK_ENABLE();
//
// /* Enable backup domain for LSE/RTC control */
// HAL_PWR_EnableBkUpAccess();
//
// /* Swith off LSE clock (to make sure RTC is off) */
// LSE_OFF_Config();
//
// /* Configure the main internal regulator output voltage (Range1 by default)*/
// HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
//
// /* Disable Power Clock */
// __HAL_RCC_PWR_CLK_DISABLE();
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LPUART1_UART_Init();
MX_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init();
/* USER CODE BEGIN 2 */
buf_len = sprintf(UART_Buffer, "\n\r Start of user code \n\r");
HAL_UART_Transmit(&hlpuart1, (uint8_t *)UART_Buffer, buf_len, 100);
test_standby(); // 0.65 mA -> Down to 0.6 mA after updated clock setting
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
|
|