都没人回答,改了一些,我现在把自己的BOOTLOADER下载到USER AREA(0X8000--0X9FFF),并通过自己的BOOTLOADER将应用程序下载到0xA000--0x27fff区域,然后send Go Command(0x21+0xDE+0xA000+checksum),一切都应答正常了。然后Reset运行,bootloader代码执行了如下:
if(GPIO_ReadInputData(BL_ENABLE_PORT) & GPIO_PIN_0)
{
//if user application is not virgin - valid reset vector jump
if((*((@far u8*)MainUserApplication)==0xA2) || (*((@far u8*)MainUserApplication)==0xAC))
{
GPIO_DeInit(BL_ENABLE_PORT); //de-init pull-up
//reset stack pointer (lower byte - because compiler decreases SP with some bytes)
_asm("LDW X, SP ");
_asm("LD A, $FF");
_asm("LD XL, A ");
_asm("LDW SP, X ");
// then jump to user application
_asm("JPF [_MainUserApplication]");
}
}
执行了上面的_asm("JPF [_MainUserApplication]");
其中:
#define MAIN_USER_RESET_ADDR 0xA000ul
const TFunction MainUserApplication = (TFunction)MAIN_USER_RESET_ADDR;
而在我的应用程序中:
在STVD工具project settings中的linker--》input中将vector addr 改为 0xa000,code segment的开始地址改为0xa080
并将stm8_interrupt_vector.c中的中断指令地址改为0xa200,
程序还是跑不起来,不知道哪错了。还有哪些要修改的???
|