iar 中mac文件中CheckRemap()分析
CheckRemap()
{
//* Read the value at 0x0
__mac_i_hb=__readMemory32(0x00000000,"Memory"); //读出0x0000地址上的数据。
__mac_i =__mac_i_hb+1; //加1后再写进去
__writeMemory32(__mac_i,0x00,"Memory");
__mac_pt =__readMemory32(0x00000000,"Memory");//再读出来。
__writeMemory32(__mac_i_hb,0x00,"Memory");//数据还原
if (__mac_i_hb!= __mac_pt) //如不相等,就说明没有把读据写入flash了,就说明是remap了。
{
__message "------------------------------- The Remap is done ----------------------------------------"; //打出信息
//* Toggel RESET The remap
__writeMemory32(0x00000001,0xFFFFFF00,"Memory");
} else { //如果相等就说明是写入ram了。
__message "------------------------------- The Remap is NOT -----------------------------------------";
}
}
因为在arm中Flash不能通过str这样的程序写入数据,只能用jtag写入.先写0x0一个数,然后读出来,如果写成功,说明RAM映射在 0x0的位置,如果RAM不是映射到0x0的位置,肯定就写到flash里去了。这样写flash是写不进的。如果写不成功,就写映射寄存器
|