如下图,在执行到HAL_FLASH_Program过程时,程序会跳入硬件错误,想了解可能是什么原因导致的,以及应该怎么解决 uint16_t MEM_If_Write_FS(uint8_t *src, uint8_t *dest, uint32_t Len){ /* USER CODE BEGIN 3 */ uint32_t i=0; printf("MEM_If_Write_FS->src:0x%x\r\n",src); printf("MEM_If_Write_FS->dest:0x%x\r\n",dest); printf("MEM_If_Write_FS->Len:%d\r\n",Len); for(i=0;i< Len; i += 4){ /*Devicevoltagerangesupposedtobe[2.7Vto3.6V],theoperationwill bedonebybyte*/ if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD,(uint32_t)(dest+i),*(uint32_t*)(src+i))==HAL_OK){ /*Checkthewrittenvalue*/ if(*(uint32_t*)(src+i)!=*(uint32_t*)(dest+i)){ /*Flashcontentdoesn'tmatchSRAMcontent*/ printf("Flash content doesn't match SRAM content\r\n"); return(USBD_FAIL); } }else{ /*ErroroccurredwhilewritingdatainFlashmemory*/ printf("Error occurred while writing data in Flashmemory\r\n"); return(USBD_FAIL); } } // UNUSED(src); // UNUSED(dest); // UNUSED(Len); printf("MEM_If_Write_FS OK\r\n"); return (USBD_OK); /* USER CODE END 3 */}
|