这里有一段PE生产的初始化函数,大家也可以自己用PE来做:
/*
** ===================================================================
** Method : _EntryPoint (bean MC9S12DP256_112)
**
** Description :
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
extern void _Startup(void); /* Forward declaration of external startup function declared in file Start12.c */
#pragma CODE_SEG __NEAR_SEG NON_BANKED
#define INITRG_ADR 0x0011 /* Register map position register */
#pragma NO_FRAME
#pragma NO_EXIT
void _EntryPoint(void)
{
/*** ### MC9S12DP256BCPV "Cpu" init code ... ***/
/*** PE initialization code after reset ***/
/* Initialization of the registers INITRG, INITRM, INITEE is done to protect them to be written accidentally later by the application */
*(byte*)INITRG_ADR = 0; /* Set the register map position */
asm("nop"); /* nop instruction */
/* INITRM: RAM15=0,RAM14=0,RAM13=0,RAM12=0,RAM11=0,??=0,??=0,RAMHAL=1 */
setReg8(INITRM, 1); /* Set the RAM map position */
/* INITEE: EE15=0,EE14=0,EE13=0,EE12=0,??=0,??=0,??=0,EEON=1 */
setReg8(INITEE, 1); /* Set the EEPROM map position */
/* MISC: ??=0,??=0,??=0,??=0,EXSTR1=1,EXSTR0=1,ROMHM=0,ROMON=1 */
setReg8(MISC, 13);
/* EBICTL: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,ESTR=0 */
setReg8(EBICTL, 0);
/* PEAR: NOACCE=0,??=0,PIPOE=0,NECLK=0,LSTRE=0,RDWE=0,??=0,??=0 */
setReg8(PEAR, 0);
/* CLKSEL: PLLSEL=0,PSTP=0,SYSWAI=0,ROAWAI=0,PLLWAI=0,CWAI=0,RTIWAI=0,COPWAI=0 */
setReg8(CLKSEL, 0); /* Select clock source from XTAL and set bits in CLKSEL reg. */
/*** End of PE initialization code after reset ***/
__asm("jmp _Startup"); /* Jump to C startup code */
}
#pragma CODE_SEG DEFAULT
|