我在AN2295SW例程的IAR工程基础上修改,打算做MK20DX256VLL7的bootloader工程。
我的目标板上使用8MHz外部晶体,把115200波特率调试输出正确后,连接目标板,运行AN2295SW\masters\release\win_hc08sprg.exe,
出现
Waiting for HC(S)08 reset ACK (timeout: 10s)...received 0xfc (good).
Calibration break pulse sent. Count: 3
Can't read MCU info. Could be protocol error.
(Or forgot to set single wire mode?)
在IAR工程里插入断点,观察SDID为0x2098,其中REVID=0x2,FAMID=0x1,PINID=0x8;
查阅文档K22P100M120SF5RM.pdf发现这三个值是正常的。
下面问题出来了:
在AN2295SW\masters\common_sources\prog.c(这里的prog.c是win_hc08sprg.exe的源码文件之一)发现
t_sdid sdidprops[]=
{
...
{0x1D0, BL_KINETIS, "Kinetis K70", -1 ,-1},
{0x140, BL_KINETIS, "Kinetis K60", -1 ,-1},
{0x130, BL_KINETIS, "Kinetis K40", -1 ,-1},
{0x120, BL_KINETIS, "Kinetis K30", -1 ,-1},
{0x110, BL_KINETIS, "Kinetis K20", -1 ,-1},
{0x100, BL_KINETIS, "Kinetis K10", -1 ,-1},
{0x0480,BL_KINETIS, "Kinetis KLxx", -1 ,-1},
{SDID_UNDEF,BL_UNKNOWN, "unknown derivative", -1 ,-1} // last entry
do not remove
};
在下面有
int sdid2index(short sdid)
{
int i=0;
if (bl_version == BL_KINETIS)
sdid &= 0x0ff0; // remove the lower 4 bits that has information about package & 4 bits about the revision Id
do
{
if(sdidprops.sdid == sdid)
return i;
} while(sdidprops[++i].sdid != SDID_UNDEF);
return i;
}
也就是说win_hc08sprg.exe把读到的sdid与上0x0ff0,去掉版本ID号。
用0x2098 & 0x0ff0 = 0x0090,而不是t_sdid sdidprops[]里K20对应的0x110。
请各位高手看看这是怎么回事? |