#if defined(__SET_RESET_VECTOR__)
void __interrupt 0 _Startup(void) {
#else
void _Startup(void) {
#endif
/* purpose: 1) initialize the stack
2) initialize the RAM, copy down init data etc (Init)
3) call main;
parameters: NONE
called from: _PRESTART-code generated by the Linker
or directly referenced by the reset vector */
/* Enable the Digital input buffer for bit0 */
ATD0DIEN = 0x01;
/* wait 2 cycles */
asm PSHA;
asm PSHA;
if(PORTAD0_BIT0)
//if(PORTE & 0x20)
{
asm JMP [0xFFFE-BootBlkSize,pcr]/* Run user Program */
}
else
{
_DISABLE_COP();
/* My Working RAM is from 0x5000 - 0x57FF */
INITRM = 0x50;
INITEE = 0x21; /* EEPROM if available is located from 0x2000 */
/* initialize the stack pointer */
INIT_SP_FROM_STARTUP_DESC(); /*lint !e522 asm code */ /* HLI macro definition in hidef.h */
// Init(); /* zero out, copy down, call constructors */
__asm {
ZeroOut:
LDX _startupData.pZeroOut ; *pZeroOut
LDY _startupData.nofZeroOuts ; nofZeroOuts
BEQ CopyDown ; if nothing to zero out
NextZeroOut: PSHY ; save nofZeroOuts
LDY 2,X+ ; start address and advance *pZeroOut (X = X+4)
LDD 2,X+ ; byte count
NextWord: CLR 1,Y+ ; clear memory byte
DBNE D, NextWord ; dec byte count
PULY ; restore nofZeroOuts
DEY ; dec nofZeroOuts
BNE NextZeroOut
CopyDown:
LDX _startupData.toCopyDownBeg ; load address of copy down desc.
NextBlock:
LDD 2,X+ ; size of init-data -> D
BEQ funcInits ; end of copy down desc.
LDY 2,X+ ; load destination address
Copy: MOVB 1,X+,1,Y+ ; move a byte from ROM to the data area
DBNE D,Copy ; copy-byte loop
BRA NextBlock
funcInits: ; call of global construtors is only in c++ necessary
}
/* Jump to main(); Use JMP instead of CALL to not use space on Stack*/
asm JMP main;
}
}
This is the Start12.c file that is included with the AN3275SW. When I run my code the microcontroller just hangs. I then set a breakpoint at asm JMP main and ran the code, it never reached the breakpoint and just hung. I am using S12P128. Are there any device-specific changes I need to make in the code to get it working?
--
Cmux