我使用STM32G431CB(和HAL(使用DMA记录ADC数据,控制/读取GPIO,通过I2C和USB CDC(虚拟通信端口(进行通信,并使用定时器。我已经验证了这些外围设备中的每一个在开发板(NUCLEO-G431KB(和我的48引脚版本的同一芯片的自定义板(STM32G431CB(上都能正常工作。
然而,我遇到的问题是,程序偶尔会跳转到地址为0x1fff4be0的指令。这在系统内存中。在检查了拆卸之后,我没有看到任何指令会导致它在这里分支。在运行一个或几个外围设备的该程序的不同版本中,当调用不同的HAL函数时会发生这种跳跃,包括:
- HAL_GPIO_ReadPin
- HAL_GPIO_WritePin
- HAL_I2C_Master_Transmit
- HAL_ADC_Start_DMA
我认为调用的函数和跳转到系统内存之间没有任何相关性。
是什么原因导致STM32出现这种情况?我正在尝试使用PB8-BOOT0作为GPIO输出。当我未配置PB8-BOOT0(重置状态(时,我不会遇到这个问题。
main.c:
#include "main.h"
#include "usb_device.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdint.h>
#include "mymain.h"
#include "usbd_cdc_if.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
I2C_HandleTypeDef hi2c3;
TIM_HandleTypeDef htim6;
TIM_HandleTypeDef htim7;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC1_Init(void);
static void MX_DMA_Init(void);
static void MX_I2C3_Init(void);
static void MX_TIM7_Init(void);
static void MX_TIM6_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint16_t ADC_result[4]; // ADC results: {TEMP_SENSOR, AC_CHG, R_SLIDER, L_SLIDER}
uint8_t I2Cdata;
uint8_t USB_tx_buffer[24];
struct SB_data SB1;
struct SB_data SB2;
uint16_t GPIO_data = 0x00c0;
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
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 */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_DMA_Init();
MX_I2C3_Init();
MX_USB_Device_Init();
MX_TIM7_Init();
MX_TIM6_Init();
/* USER CODE BEGIN 2 */
HAL_DMA_Init(&hdma_adc1);
TPS55288Q1_Init();
// GPIO initial states
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); // Initialize USB 3 hub in reset until tablet supplies power on TAB_DCOUT->VBUS_DET3V3 (PA2)
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_RESET); // Initialize 5V, 3.3V, 2.5V, 1.2V supplies off (net Enable_Power)
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_RESET); // Initialize L mouse off
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); // Enable EN_EXT_USB_PWR by default
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_SET); // DISABLE_CHG1
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); // DISABLE_CHG2
// BEGIN TESTING ONLY //
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
// END TESTING ONLY //
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
// ADC DMA Start
//HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADC_result, 4);
// Log GPIO data
log_GPIO_data();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 12;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
}
/**
* @brief ADC1 Initialization Function
* @param None
* @retval None
*/
static void MX_ADC1_Init(void)
{
/* USER CODE BEGIN ADC1_Init 0 */
/* USER CODE END ADC1_Init 0 */
ADC_MultiModeTypeDef multimode = {0};
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.GainCompensation = 0;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.NbrOfConversion = 4;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = ENABLE;
hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
hadc1.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure the ADC multi-mode
*/
multimode.Mode = ADC_MODE_INDEPENDENT;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_2;
sConfig.Rank = ADC_REGULAR_RANK_2;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_4;
sConfig.Rank = ADC_REGULAR_RANK_3;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_TEMPSENSOR_ADC1;
sConfig.Rank = ADC_REGULAR_RANK_4;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */
}
/**
* @brief I2C3 Initialization Function
* @param None
* @retval None
*/
static void MX_I2C3_Init(void)
{
/* USER CODE BEGIN I2C3_Init 0 */
/* USER CODE END I2C3_Init 0 */
/* USER CODE BEGIN I2C3_Init 1 */
/* USER CODE END I2C3_Init 1 */
hi2c3.Instance = I2C3;
hi2c3.Init.Timing = 0x00303D5B;
hi2c3.Init.OwnAddress1 = 0;
hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c3.Init.OwnAddress2 = 0;
hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c3) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C3_Init 2 */
/* USER CODE END I2C3_Init 2 */
}
/**
* @brief TIM6 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM6_Init(void)
{
/* USER CODE BEGIN TIM6_Init 0 */
/* USER CODE END TIM6_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM6_Init 1 */
/* USER CODE END TIM6_Init 1 */
htim6.Instance = TIM6;
htim6.Init.Prescaler = 1600-1;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 19999;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM6_Init 2 */
/* USER CODE END TIM6_Init 2 */
}
/**
* @brief TIM7 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM7_Init(void)
{
/* USER CODE BEGIN TIM7_Init 0 */
/* USER CODE END TIM7_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM7_Init 1 */
/* USER CODE END TIM7_Init 1 */
htim7.Instance = TIM7;
htim7.Init.Prescaler = 1600-1;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
htim7.Init.Period = 121;
htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM7_Init 2 */
/* USER CODE END TIM7_Init 2 */
}
/**
* Enable DMA controller clock
*/
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMAMUX1_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
/* DMA interrupt init */
/* DMA1_Channel1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
}
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4|GPIO_PIN_10, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_8, GPIO_PIN_RESET);
/*Configure GPIO pins : PA4 PA10 */
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PB2 PB11 PB12 PB8 */
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
/* USER CODE BEGIN 4 */
// Initializes TPS55288Q1 buck-boost converters by configuring external voltage divider, resetting error flags, and disabling output
void TPS55288Q1_Init() {
I2Cdata = 0b10000011;
HAL_I2C_Mem_Write(&hi2c3, TPS55288Q1_TAB_DCIN_DEV_ADDR<<1, TPS55288Q1_VOUT_FS_ADDR, 1, &I2Cdata, 1, 2); // Use external voltage divider
HAL_I2C_Mem_Write(&hi2c3, TPS55288Q1_12V_DEV_ADDR<<1, TPS55288Q1_VOUT_FS_ADDR, 1, &I2Cdata, 1, 2);
HAL_I2C_Mem_Read(&hi2c3, TPS55288Q1_TAB_DCIN_DEV_ADDR<<1, TPS55288Q1_STATUS_R, 1, &I2Cdata, 1, 2); // Read and reset error flags
HAL_I2C_Mem_Read(&hi2c3, TPS55288Q1_12V_DEV_ADDR<<1, TPS55288Q1_STATUS_R, 1, &I2Cdata, 1, 2);
I2Cdata = 0b00100000; // ~OE, all else default
HAL_I2C_Mem_Write(&hi2c3, TPS55288Q1_TAB_DCIN_DEV_ADDR<<1, TPS55288Q1_MODE_R_ADDR, 1, &I2Cdata, 1, 2);
HAL_I2C_Mem_Write(&hi2c3, TPS55288Q1_12V_DEV_ADDR<<1, TPS55288Q1_MODE_R_ADDR, 1, &I2Cdata, 1, 2);
}
// switches the channel being read on ADC1
void ADC1_Select_Channel(uint32_t channel) {
ADC_ChannelConfTypeDef sConfig = {0};
sConfig.Channel = channel;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_12CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) {
Error_Handler();
}
}
// reads GPIO inputs that will be transmitted to the tablet
// {DISABLE_CHG2, DISABLE_CHG1, ~BATID2, ~BATID1, RB2, RB1, LB2, LB1}
void log_GPIO_data() {
GPIO_data &= 0xffc0; // clear bottom 6 bits
GPIO_data |= HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_6) | (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) << 1) |
(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_0) << 2) | (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_1) << 3) |
(!HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13) << 4) | (!HAL_GPIO_ReadPin(GPIOF, GPIO_PIN_1) << 5);
}
void set_bit(uint16_t* data, uint8_t bit_pos, uint8_t value) {
if (value) {
*data |= 1<<bit_pos;
} else {
*data &= ~(1<<bit_pos);
}
}
// Returns 1 if either battery is inserted and not fully discharged or if AC_CHG_Det is 1. Indicates active power source
uint8_t PWRsource_det() {
return (bat1_inserted() && (SB1.status[0] & 0x10)) || (bat2_inserted() && (SB2.status[0] & 0x10)) || (GPIO_data & 0x0100);
}
// Returns 1 if Smart Battery 1 is inserted, 0 otherwise
uint8_t bat1_inserted() { // internal pull down resistor on smart battery when detected. Pin is low when battery is inserted
return GPIO_data & (1<<4);
}
// Returns 1 if Smart Battery 2 is inserted, 0 otherwise
uint8_t bat2_inserted() { // internal pull down resistor on smart battery when detected. Pin is low when battery is inserted
return GPIO_data & (1<<5);
}
// loads the USB CDC transmission buffer. Multi-byte data fields are Little Endian. Ends in nr.
void load_USB_TX_buffer(uint8_t* TX_buffer, struct SB_data* bat1, struct SB_data* bat2, uint16_t* ADC_readings, uint16_t GPIO_inputs, uint16_t temperature) {
TX_buffer[0] = bat1->status[0];
TX_buffer[1] = bat1->status[1];
TX_buffer[2] = bat1->timetoempty[0];
TX_buffer[3] = bat1->timetoempty[1];
TX_buffer[4] = bat1->voltage[0];
TX_buffer[5] = bat1->voltage[1];
TX_buffer[6] = bat1->chgpercent;
TX_buffer[7] = bat2->status[0];
TX_buffer[8] = bat2->status[1];
TX_buffer[9] = bat2->timetoempty[0];
TX_buffer[10] = bat2->timetoempty[1];
TX_buffer[11] = bat2->voltage[0];
TX_buffer[12] = bat2->voltage[1];
TX_buffer[13] = bat2->chgpercent;
TX_buffer[14] = (uint8_t) (ADC_readings[1] >> 8); // Right slider
TX_buffer[15] = (uint8_t) ADC_readings[1];
TX_buffer[16] = (uint8_t) (ADC_readings[0] >> 8); // Left Slider
TX_buffer[17] = (uint8_t) ADC_readings[0];
TX_buffer[18] = (uint8_t) (temperature >> 8); // Temperature sensor
TX_buffer[19] = (uint8_t) temperature;
TX_buffer[20] = (uint8_t) (GPIO_inputs & 0xff);
TX_buffer[21] = (uint8_t) ((GPIO_inputs >> 8) & 0xff);
TX_buffer[22] = (uint8_t) 'n';
TX_buffer[23] = (uint8_t) 'r';
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim) {
if (htim == &htim6) { // USB RX Comms 2s timeout
HAL_TIM_Base_Stop_IT(&htim7); // Stop USB TX
HAL_TIM_Base_Stop_IT(&htim6);
// disable 12V and TAB_DCIN
uint8_t data = 0b00100000; // ~OE, all else default
HAL_I2C_Mem_Write(&hi2c3, TPS55288Q1_TAB_DCIN_DEV_ADDR<<1, TPS55288Q1_MODE_R_ADDR, 1, &data, 1, 10);
data = 0b00100100; // ~OE, address=0x75, all else default
HAL_I2C_Mem_Write(&hi2c3, TPS55288Q1_12V_DEV_ADDR<<1, TPS55288Q1_MODE_R_ADDR, 1, &data, 1, 10);
// disable 5V, 3.3V, 2.5V, 1.2V supplies (net Enable_Power)
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_RESET);
} else if (htim == &htim7) { // USB TX call (82Hz)
uint16_t temperature = __HAL_ADC_CALC_TEMPERATURE(3300, ADC_result[3], ADC_RESOLUTION_12B);
load_USB_TX_buffer(USB_tx_buffer, (struct SB_data*) &SB1, (struct SB_data*) &SB2, (uint16_t*) ADC_result, GPIO_data, temperature);
CDC_Transmit_FS(USB_tx_buffer, sizeof(USB_tx_buffer));
/* ** UART DEBUG **
uint8_t usart_d[] = "SRSnr";
HAL_UART_Transmit(&huart2, usart_d, sizeof(usart_d), 2);
*/
}
}
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %drn", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
您的微控制器正在执行嵌入式引导加载程序。
根据以下一种或多种情况可能导致的微观情况:
- Obion字节设置
- BOOT0引脚
- BOR期间flash的第一个单词的内容
如果未通过OBL_LAUNCH显式调用更新,则仅在BOR上加载选项字节。闪烁空标志(最后一点(也仅在BOR期间评估。没有BOR,就不可能进行更新。您可以通过引导程序接口使用适当的命令退出引导程序。
可能是因为您使用BOOT0作为GPIO(除非它是STM32G4的特定功能,否则我只知道H7和L4(。
我认为,如果由于任何原因发生重置,并且信号处于错误状态,您最终将在System Flash上启动。