使用dsp品台28377d来实现在线升级的功能。
方案 : 升级程序 + 应用程序
升级程序 : 主要的目的是将上位机发送过来的应用程序数据(ccs编译生成的.bin文件)烧写到指定位置,之后在跳转到应用程序执行。
应用程序 : 等待升级的程序
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
升级代码段 :
flash_programming_cpu01.c 1 //######################################################################### 2 // FILE: flash_programming_cpu01.c 3 // TITLE: Flash Programming Example for F2837xD. 4 // 5 //! \addtogroup dual_example_list 6 //! <h1> Flash Programming </h1> 7 //! 8 //! This example demonstrates F021 Flash API usage. 9 // 10 //######################################################################### 11 // $TI Release: F2837xD Support Library v170 $ 12 // $Release Date: Mon Sep 21 16:52:10 CDT 2015 $ 13 // $Copyright: Copyright (C) 2013-2015 Texas Instruments Incorporated - 14 // http://www.ti.com/ ALL RIGHTS RESERVED $ 15 //######################################################################### 16 17 #include "F28x_Project.h" // Device Headerfile and Examples Include<span style="white-space:pre"> </span>File 18 #include "F2837xD_Ipc_drivers.h" 19 20 #include <string.h> 21 22 //Include Flash API example header file 23 #include "flash_programming_c28.h" 24 25 #define ENTRYADDR 0x88000 26 27 extern void lightflash(void); 28 29 //************************************************************************* 30 // FILE Flash API include file 31 //************************************************************************* 32 #include "F021_F2837xD_C28x.h" 33 34 //Data/Program Buffer used for testing the flash API functions 35 #define WORDS_IN_FLASH_BUFFER 3608 // Programming data buffer, words 36 37 uint16 Buffer[WORDS_IN_FLASH_BUFFER + 1]; 38 uint32 *Buffer32 = (uint32 *)Buffer; 39 40 #pragma DATA_SECTION(pbuffer , "PDATASAVE"); 41 uint16 pbuffer[WORDS_IN_FLASH_BUFFER]= { 42 #include "P_DATA.h" 43 }; 44 45 //************************************************************************* 46 // Prototype of the functions used in this example 47 //************************************************************************* 48 void Example_CallFlashAPI(void); 49 50 //************************************************************************* 51 // This is an example code demonstrating F021 Flash API usage. 52 // This code is in Flash 53 //************************************************************************* 54 void main(void) 55 { 56 // Step 1. Initialize System Control: 57 // Enable Peripheral Clocks 58 // This example function is found in the F2837xD_SysCtrl.c file. 59 InitSysCtrl(); 60 61 IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH); 62 63 InitGpio(); 64 65 InitPieCtrl(); 66 67 IER = 0x0000; 68 IFR = 0x0000; 69 70 InitPieVectTable(); 71 72 EINT; // Enable Global interrupt INTM 73 74 // Jump to RAM and call the Flash API functions 75 Example_CallFlashAPI(); 76 77 DELAY_US(100000); 78 79 static void (*APPEntry)(void); 80 81 APPEntry = (void (*)(void))(ENTRYADDR); 82 83 ESTOP0; 84 85 (*APPEntry)(); 86 87 while(1); 88 89 } 90 91 //************************************************************************* 92 // Example_CallFlashAPI 93 // 94 // This function will interface to the flash API. 95 // Flash API functions used in this function are executed from RAM 96 //************************************************************************* 97 #pragma CODE_SECTION(Example_CallFlashAPI , "ramfuncs"); 98 void Example_CallFlashAPI(void) 99 { 100 uint32 u32Index = 0; 101 uint16 i = 0; 102 103 Fapi_StatusType oReturnCheck; 104 volatile Fapi_FlashStatusType oFlashStatus; 105 106 // Gain pump semaphore 107 SeizeFlashPump(); 108 109 EALLOW; 110 Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0; 111 EDIS; 112 113 EALLOW; 114 115 oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 200);//for now keeping it out 116 117 if(oReturnCheck != Fapi_Status_Success) 118 { 119 // Check Flash API documentation for possible errors 120 while(1); 121 } 122 123 oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0); 124 if(oReturnCheck !=