Hey guys!
I'm making an IC programmer to support this device. And I have reference this Manual.
http://cache.freescale.com/files/microcontrollers/doc/ref_manual/KL16P80M48SF4RM.pdf
Now I can already use SWD interface to read IDR register in MDM-AP.
The problem is how to program KL16 flash sector.
Thank you for your help,
Regarts!
Hi Shawn Lee,
Thank you for your question in our community.
Actually, about the program flash sector, we have an application AN4835 for your reference:
http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4835.pdf?fromsite=zh-Hans
You can find program section in 4.3.1.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
您好 JingJing Zhong,
谢谢你的回覆,我已经看了附加的文档了。
在文档中4.3.1写到,要将欲写入的Data写入FlexRAM,再透过SWD写入FCCOB命令、清除CCIF。
但在KL16P80M48SF4RM.pdf中4.2提到:
我尝试访问过FCCOB,但是我写入Data后,再将Data读取出来却没有变化。我希望有一个正确的方向,谢谢!
Hi Shawn Lee,
请问你是使用什么通过SWD给KL16芯片编程的呢? 是基于什么平台?
另外,你访问FCCOB的具体过程是怎样的呢?
SWD编程这块内容涉及到ARM内核的控制,我已经向相关专家请教,看是否有一些参考例程可以给出,目前正在等待他们的回复。
一旦有结果,我就会告诉你,所以还请耐心等待下。
Regards,
Jingjing
您好 JingJing Zhong,
我是使用自家生产的IC programmer 透过KL16的AHB-AP 访问FCCOB的,具体的方法在ARM的手册里有写到,
在KL16P80M48SF4RM.pdf的Figure 9.1 也有相关的说明。目前我只能透过AHB-AP存取SRAM,和读取整个System Memory。参考KL16P80M48SF4RM.pdf中4.2 的System Memory Map,可见AHB-AP似乎没有权限对FCCOB写入Data,所以才希望freescale提供其他方法或例程来存取Data。希望能早点得到回覆,谢谢!!
Shawn Lee, 您好!
我看了昨天推荐你的AN4835文档,
还有
所以,可以知道FTFA是不支持program section command的,而FTFA就是KL系列的Flash模块。你能否用program longword试试,看是否可以直接操作flash?
在SWD工程师回复我之前,你可以先试试program longword命令。
另外,可以告诉我你刚贴的AHB-AP图的文档具体名称吗?
Jingjing
您好 JingJing Zhong,
U32 FlashCmdSeq(U8 cmd_code, //command code
FlashCmdSeq_ADDR ADDR, //address
FlashCmdSeq_DATA WtoWr, //word to write
U8 index) //command count
{
U8 counter,err;
err=E_OK;
for(counter=0; counter<index; counter++)
{
switch (counter)
{
case 0: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB0);
err=SWDWrAPReg(ahbap_rw_DRW, cmd_code);
break;
case 1: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB1);
err=SWDWrAPReg(ahbap_rw_DRW, ADDR.Addr24_16);
break;
case 2: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB2);
err=SWDWrAPReg(ahbap_rw_DRW, ADDR.Addr15_8);
break;
case 3: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB3);
err=SWDWrAPReg(ahbap_rw_DRW, ADDR.Addr7_0);
break;
case 4: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB4);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE0);
break;
case 5: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB5);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE1);
break;
case 6: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB6);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE2);
break;
case 7: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB7);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE3);
break;
case 8: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB8);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE4);
break;
case 9: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOB9);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE5);
break;
case 10: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOBA);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE6);
break;
case 11: err=SWDWrAPReg(ahbap_rw_TAR, FTFA_FCCOBB);
err=SWDWrAPReg(ahbap_rw_DRW, WtoWr.BYTE7);
break;
default: break;
}
}
return err;
}
U32 ISP_SEQ(U8 cmd_code, //command code
FlashCmdSeq_ADDR ADDR, //address
FlashCmdSeq_DATA WtoWr, //word to write
U8 index) //command count
{
volatile unsigned int cmd_data;
U8 err = E_OK;
err = SWDRdMemWd(FTFA_FSTAT, &cmd_data)
if((cmd_data&0x30)!=0)
err = SWDWrMemWd(FTFA_FSTAT, 0x30); // write 1 to clear error flags(ACCERR & FPVIOL)
err = FlashCmdSeq(cmd_code, ADDR, WtoWr, index);
err = SWDWrMemWd(FTFA_FSTAT, 0x80); // write 1 to clear flag (executes command)
LP_wait_ms(15);
err = SWDRdMemWd(FTFA_FSTAT, &cmd_data);
if(!(cmd_data&0x80)) //if CCIF(bit7) have not set to 1 return error
return err;
}
您好 JingJing Zhong,
图在ARM手册的Figure8.1,档名IHI0031A_ARM_debug_interface_v5.pdf
我已经测试过KL16P80M48SF4RM.pdf 中27.4.8.2的command,包刮Program Longword、Erase Flash Sector、Erase All Blocks,但都无法写入FCCOB。所以我才猜测不能透过AHB-AP而是别种方法。
Regards!
Shawn