近日发现COSMIC的far指针初始化老是有问题,以下是一个演示:
#define FLASH_APP_ADDR 0x9FF0ul
@far unsigned char * app_start_addr;
unsigned char check_app_valid(@far unsigned char * start_addr)
{
if( *start_addr == 0x82 )
return 1;
else
return 0;
}
main()
{
unsigned char app_valid;
app_start_addr = (@far unsigned char *)FLASH_APP_ADDR;
app_start_addr += 0x10;
if( check_app_valid(app_start_addr) )
{
app_valid = 1;
}
while (1);
}
用仿真器观察,当程序执行完下面这句后
app_start_addr = (@far unsigned char *)FLASH_APP_ADDR;
app_start_addr的值是0xF0, 而不是预期的0x9FF0
执行完 app_start_addr += 0x10后,app_start_addr变成0x100
从而传递进函数check_app_valid的参数也是不对的。
真是郁闷,各位兄弟分析并测试一下,是我的错误呢还是COSMIC的BUG? |