2011年10月12日 星期三

讓程式可利用DFU燒錄與啟動

修改Code Memory的起始位置

如勾選Use Memory Layout from Target Dialog


設定ROM的起始位置Start加上0x3000,Size減少0x3000,前0x3000為DFU使用空間

  
未勾選Use Memory Layout from Target Dialog

  
更改Scatter檔案
檔案"XXX.sct"

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x08003000 0x0003D000  {    ; load region size_region
  ER_IROM1 0x08003000 0x0003D000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_RAM1 0x60000000 0x00040000  {  ; RW data
   .ANY (+RW +ZI)
  }
;  RW_RAM2 0x64000000 0x00080000  {
;   .ANY (+RW +ZI)
;   Memory.o(ZI_RAM2)
;  }
  RW_IRAM1 0x20000000 0x0000C000  {
   .ANY (+RW +ZI)
  }
}

如果程式使用到中斷處理,需跟改NVIC Table位置
在一般Example中可在"main.c"找到

/*******************************************************************************
* Function Name  : NVIC_Configuration
* Description    : Configures NVIC and Vector Table base location.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void NVIC_Configuration(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;
  
#ifdef  VECT_TAB_RAM  
  /* Set the Vector Table base location at 0x20000000 */ 
  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 
#else  /* VECT_TAB_FLASH  */
  /* Set the Vector Table base location at 0x08000000 */ 
  NVIC_SetVectorTable(0x08003000, 0x0);   
#endif


在USB Example中可在"hw_config.c"找到

/*******************************************************************************
* Function Name  : USB_Interrupts_Config
* Description    : Configures the USB interrupts
* Input          : None.
* Return         : None.
*******************************************************************************/
void USB_Interrupts_Config(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;

#ifdef  VECT_TAB_RAM
  /* Set the Vector Table base location at 0x20000000 */
  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else  /* VECT_TAB_FLASH */
  /* Set the Vector Table base location at 0x08000000 */
  NVIC_SetVectorTable(0x08003000, 0x0);
#endif

沒有留言:

張貼留言