首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[原创]bootloader从DP256到XEP100的移植问题

[原创]bootloader从DP256到XEP100的移植问题

各位大虾,小弟之前按AN2546的NoteBook做了MC9S12DP256的bootloader,现在需要移植到MC9S12XEP100,但flash擦写和很多寄存器设置有很大区别,哪位仁兄能有任何指教或做过类似工作能指点一二,不胜感激.先在此谢过
Walk slowly,but never stop.

了解的帮帮忙啊

Walk slowly,but never stop.

S12XE的Flash操作更加简洁,都是通过操作CCOB命令寄存器来实现。所有的擦除和编程只要通过寄存器的操作就可以实现了。关键是要写一个CCOB命令的函数。下面是一个经过验证的CCOB函数,在freescale的s12xep100的demo板上试过。

/******************************************************************************
Function Name : LaunchFlashCommand
Notes : This function does not check if the Flash is erased.
This function does not explicitly verify that the data has been
sucessfully programmed.
This function must be located in RAM or a flash block not
being programmed.
******************************************************************************/
tU08 LaunchFlashCommand(char params,tU08 command,tU08 ccob0,tU16 ccob1,tU16 ccob2,tU16 ccob3,tU16 ccob4,tU16 ccob5)
{
if(FTM.fstat.bit.ccif == 1) {

FTM.fstat.byte = (FPVIOL | ACCERR); // Clear any error flags

FTM.fccobix.byte = 0; // Write the command id / ccob0
FTM.fccob.byte.hi = command;
FTM.fccob.byte.lo = ccob0;

if(++FTM.fccobix.byte != params) {
FTM.fccob.word = ccob1; // Write next data word to CCOB buffer.
if(++FTM.fccobix.byte != params) {
FTM.fccob.word = ccob2; // Write next data word to CCOB buffer.
if(++FTM.fccobix.byte != params) {
FTM.fccob.word = ccob3; // Write next data word to CCOB buffer.
if(++FTM.fccobix.byte != params) {
FTM.fccob.word = ccob4; // Write next data word to CCOB buffer.
if(++FTM.fccobix.byte != params)
FTM.fccob.word = ccob5; // Write next data word to CCOB buffer.
}
}
}
}
FTM.fccobix.byte = params-1; // This is necessary! 03082007 r66193

FTM.fstat.byte = CCIF; /* Clear command buffer empty flag by writing a 1 to it */

while (!FTM.fstat.bit.ccif) { /* wait for the command to complete */
}

return(FTM.fstat.byte); /* Return status. programmed OK */
}
else {
return(FLASH_BUSY); /* state machine busy */
}
}

另附FTM的数据结构的定义:

typedef struct /*FTM datastructure */
{
volatile tFCLKDIV fclkdiv; /*flash clock divider register */
volatile tFSEC fsec; /*flash security register */
volatile tREG08 fccobix; /*flash Common Command Object (CCOB) index register */
volatile tREG08 feccrix; /*flash ECCR index register */
volatile tFCNFG fcnfg; /*flash configuration register */
volatile tFERCNFG fercnfg; /*flash error configuration register */
volatile tFSTAT fstat; /*flash status register */
volatile tFERSTAT ferstat; /*flash error status register */
volatile tFPROT fprot; /*program flash protection register */
volatile tEPROT eprot; /*data flash (eeeprom) protection register */
volatile tFCCOB fccob; /*common command object register */
volatile tU16 etag; /*EEE tag counter */
volatile tU16 feccr; /*CCR error result*/
volatile tU08 fopt; /*flash option register */
}tFTM

非常感谢GaoTristone,很受益

Walk slowly,but never stop.

感觉AN3391比较有用

Walk slowly,but never stop.

good!

飞思卡尔8/16/32位多功能开发板/下载器:
网站:http://www.lqist.cn,
淘宝店:http://shop36265907.taobao.com
返回列表