当前位置: 首页> 娱乐> 明星 > 东莞网站优化哪里找_东莞推广系统怎么做_成功营销案例100例_网站搭建软件

东莞网站优化哪里找_东莞推广系统怎么做_成功营销案例100例_网站搭建软件

时间:2025/7/10 16:06:01来源:https://blog.csdn.net/booksyhay/article/details/146021535 浏览次数:0次
东莞网站优化哪里找_东莞推广系统怎么做_成功营销案例100例_网站搭建软件

上电过程

上电后,CPU从固定的位置读取复位向量。

这个固定的位置就是0xFFFE。是芯片厂商出厂时预设好的。

这个地址是NON_BANKED的。这个位置保存的是复位向量,实际上就是一个函数指针。该函数指针指向_Startup()函数。

map文件:

注意:程序的入口点是_Startup,不是main()。

_Startup函数是存放在0xC000位置。而0xFFFE地址的值就是0xC000.

S19文件:

_Startup()函数分析

打开 Start12.c文件,可以看到_Startup()函数。

/* The function _Startup must be called in order to initialize global variables and to call main */
/* You can adapt this function or call it from your startup code to implement a different startup */
/* functionality. *//* You should also setup the needed IO registers as WINDEF (HC12A4 only) or the COP registers to run */
/* on hardware *//* to set the reset vector several ways are possible : */
/* 1. define the function with "interrupt 0" as done below in the first case */
/* 2. add the following line to your prm file : VECTOR ADDRESS 0xfffe _Startup */
/* of course, even more posibilities exists */
/* the reset vector must be set so that the application has a defined entry point */#if defined(__SET_RESET_VECTOR__)
__EXTERN_C void __interrupt 0 _Startup(void) {
#else
__EXTERN_C void _Startup(void) {
#endif
/*  purpose:    1)  initialize the stack2)  initialize the RAM, copy down init data etc (Init)3)  call main;parameters: NONEcalled from: _PRESTART-code generated by the Linkeror directly referenced by the reset vector *//* initialize the stack pointer */INIT_SP_FROM_STARTUP_DESC(); /*lint !e522 asm code */ /* HLI macro definition in hidef.h */#if defined(_HCS12_SERIALMON)/* for Monitor based software remap the RAM & EEPROM to adhereto EB386. Edit RAM and EEPROM sections in PRM file to match these. */___INITRG = 0x00;  /* lock registers block to 0x0000 */___INITRM = 0x39;  /* lock Ram to end at 0x3FFF */___INITEE = 0x09;  /* lock EEPROM block to end at 0x0fff */
#endif/* Here user defined code could be inserted, the stack could be used */
#if defined(_DO_DISABLE_COP_)_DISABLE_COP();
#endif/* Example : Set up WinDef Register to allow Paging */
#ifdef HC812A4 /* HC12 A4 derivative needs WINDEF to configure which pages are available */
#if  (__ENABLE_EPAGE__ != 0 ||  __ENABLE_DPAGE__ != 0 || __ENABLE_PPAGE__ != 0)WINDEF= __ENABLE_EPAGE__ | __ENABLE_DPAGE__  | __ENABLE_PPAGE__;
#endif
#endif#if (defined(__MAP_RAM__) || defined(__MAP_FLASH__) || defined(__MAP_EXTERNAL__)) && !defined(__DO_SET_MMCTL1__)
#define __DO_SET_MMCTL1__
#endif#if defined(__DO_SET_MMCTL1__)/* Set the MMCTL1 byte. Please use for HCS12XE and change the bits according   *//* to your configuration.                                                      *//* Note: MMCTL1 is write once therefore please adapt this initialization here. *//* This has to be done prior to the call to Init.                              */
#define _MMCTL1_ADR (0x00000013)
#define _MMCTL1_BIT_TGMRAMON (1<<7)  /* EEE Tag RAM and FTM SCRATCH RAM visible in the memory map */
#define _MMCTL1_BIT_EEEIFRON (1<<5)  /* EEE IFR visible in the memory map                         */
#define _MMCTL1_BIT_PGMIFRON (1<<4)  /* Program IFR visible in the memory map                     */
#define _MMCTL1_BIT_RAMHM    (1<<3)  /* RAM only in the higher half of the memory map             */
#define _MMCTL1_BIT_EROMON   (1<<2)  /* Enables emulated Flash or ROM memory in the memory map    */
#define _MMCTL1_BIT_ROMHM    (1<<1)  /* FLASH or ROM only in higher Half of Memory Map            */
#define _MMCTL1_BIT_ROMON    (1<<0)  /* Enable FLASH or ROM in the memory map                     */#define _MMCTL1_SET(value)   ((*(volatile unsigned char*)_MMCTL1_ADR)= (value))#if defined(__MAP_FLASH__)_MMCTL1_SET(_MMCTL1_BIT_ROMON | _MMCTL1_BIT_EROMON);
#elif defined(__MAP_EXTERNAL__)_MMCTL1_SET(_MMCTL1_BIT_ROMON | _MMCTL1_BIT_EROMON | _MMCTL1_BIT_ROMHM);
#else /* RAM */_MMCTL1_SET(_MMCTL1_BIT_ROMON | _MMCTL1_BIT_EROMON | _MMCTL1_BIT_RAMHM | _MMCTL1_BIT_ROMHM);
#endif    
#endif#ifndef __ONLY_INIT_SPInit(); /* zero out, copy down, call constructors */
#endif/* Here user defined code could be inserted, all global variables are initilized */
#if defined(_DO_ENABLE_COP_)_ENABLE_COP(1);
#endif/* call main() */main();
}

其实,删除掉各种define,去繁存精,只干了三件事:设置栈指针SP,调用init(),然后调用main()。

从map文件中也可以验证:

BOOTLOADER设计

在有BOOT的系统中,程序分为两部分:BOOT和APP。

这里面就有两套中断。需要在BOOT中做特殊处理。

在升级过程中,接收到上位机发过来的APP的bin文件时,需要调整中断向量保存的位置。(因为APP工程中生成的中断向量也是保存在0xFF10开始的位置)

上电后,CPU还是先从BOOT开始执行。在BOOT中作一些判断,确认APP正常后,跳转到APP中去执行。但是在跳转前,需要先配置中断向量基地址寄存器(IVBR),确保中断向量指向正确的位置。

注意:IVBR是个8位的寄存器,而中断向量起始地址是16位的,其中低8位默认为0.

关键字:东莞网站优化哪里找_东莞推广系统怎么做_成功营销案例100例_网站搭建软件

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: