【iCore4 雙核心板_ARM】例程三十四:U_DISK_IAP_ARM實驗——更新升級STM32

實驗現象及操做說明:oop

一、本例程共有兩個代碼包,APP和IAP,IAP程序功能實現將APP程序升級至STM32中。ui

二、直接上電或燒寫程序將執行升級的APP應用程序。spa

三、按下按鍵上電或寫程序將進行升級,升級文件.bin文件存入在U盤中3d

BIN升級文件產生方法:code

一、編譯APP工程,產生.hex文件。htm

二、將.hex文件拖至HEX2BIN.EXE便可產生.bin文件。blog

核心代碼:ip

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_USB_HOST_Init();
  MX_FATFS_Init();

  /* USER CODE BEGIN 2 */
    if(ARM_KEY_STATE == KEY_UP)
        goto start;
    
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */
    MX_USB_HOST_Process();

  /* USER CODE BEGIN 3 */

  }
    start:
        //²âÊÔÓû§´úÂëÊÇ·ñ´ÓAPPLICATION_ADDRESS±»±à³Ì
        if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000){ 
            
            //ÌøתÖÁÓû§³ÌÐò
            JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
            Jump_To_Application = (pFunction) JumpAddress;
            
            //³õʼ»¯Óû§³ÌÐòµÄ¶ÑÕ»Ö¸Õë
            __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
            
            //ÌøתÖÁÓ¦ÓóÌÐò
            Jump_To_Application();
        }else{                
            led_trade();
        }
  /* USER CODE END 3 */

}

源代碼下載連接:get

連接:http://pan.baidu.com/s/1jIrF5jC 密碼:eec1it

iCore4連接:

相關文章
相關標籤/搜索