MyType mysymbol;/* USER CODE END 0 */FLASH_OBProgramInitTypeDef OBInit;
int main(void){
HAL_Init();
/* USER CODE BEGIN Init */ HAL_FLASH_Unlock(); HAL_FLASH_OB_Unlock(); HAL_FLASHEx_OBGetConfig(&OBInit); OBInit.OptionType = OPTIONBYTE_USER; OBInit.USERType = OB_USER_nBOOT0; OBInit.USERConfig = OB_nBOOT0_SET; HAL_FLASHEx_OBProgram (&OBInit); OBInit.OptionType = OPTIONBYTE_USER; OBInit.USERType = OB_USER_nSWBOOT0; OBInit.USERConfig = OB_BOOT0_FROM_OB; HAL_FLASHEx_OBProgram (&OBInit); HAL_FLASH_OB_Lock(); HAL_FLASH_Lock(); //这段代码的功能:重新定义BOOT0,BOOT0的数据不在从外部PIN获取,而是从内部nSWBOOT0+NBOOT0获取,当前定义,BOOT from Main Flash ; /* USER CODE END Init */
/* Configure the system clock */ SystemClock_Config();
/* USER CODE BEGIN SysInit */ EventRecorderInitialize(EventRecordAll,1U); EventRecorderStart(); //这段代码使能EVENTRECORDER ,可以使用没有SWO口的ST Link 做打印debug ; /* USER CODE END SysInit */
/* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_TIM1_Init();
|