Board logo

标题: 求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞? [打印本页]

作者: xuh5156    时间: 2009-5-15 16:41     标题: 求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞?

本帖最后由 xuh5156 于 2011-7-21 10:27 编辑

<p>求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞?>
作者: achao86926    时间: 2009-6-4 11:06

我用过,而且写了擦写程序。再擦写P-FLASH的时候,总是遇到问题,也就是你单步执行可以擦写,但是一自由运行就跑飞。有的时候还出现复位的情况,TARGET SELF-RESET DETECED,我注意到了延时的问题,还有编程电压的问题。但还是没办法解决。擦写D-FLASH的时候就没有问题。不知道你现在问题解决了没有?我用的是S12XS128的芯片写的程序,以后我们要用S12P的芯片替换。我看了一下S12P的数据手册,关于FLASH的擦除基本上与S12XS一样的。你可以参考一下。并帮助我解决一下问题。


作者: achao86926    时间: 2009-6-4 11:07

ZBUcdqYZ.rar (791 Bytes)


附件: [求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞?] ZBUcdqYZ.rar (2009-6-4 10:43, 791 Bytes) / 下载次数 378
http://bbs.eccn.com/attachment.php?aid=6944&k=dcc6c29dc90e55fe22a29ace02228e52&t=1719828744&sid=814KlH
作者: 康桥人    时间: 2009-6-4 16:04

void bscomeep_EraseSector(uint16_t ru16_DflashAddress)
{
uint8_t lub_err = ERR_OK;
/* FSTAT: ACCERR=1,FPVIOL=1 */
FSTAT = 48; /* Clear error flags */
FCCOBIX = 0; /* Clear index register */
FCCOBHI = 18; /* Erase D-Flash sector command */
FCCOBLO = 0; /* High address word */
FCCOBIX++; /* Shift index register */
FCCOB = ru16_DflashAddress+DFLASH_Write_OFFSET; /* Low address word aligned to word*/
FSTAT = 128; /* Clear flag command buffer empty */
//while (FSTAT_CCIF == 0); /* Wait to command complete */
//if (FSTAT_ACCERR || FSTAT_MGSTAT) /* Is access error or other error detected ? */
//{
// lub_err = ERR_NOTAVAIL; /* If yes then error */
//}
/// else //misra C
// /{
// }
}
/* write data to Dflash 8 byte */
void bscomeep_Write(uint16_t ru16_DflashAddress,uint16_t *ru16_Data,uint8_t Length)
{
/* FSTAT: ACCERR=1,FPVIOL=1 */
FSTAT = 48; /* Clear error flags */
FCCOBIX = 0; /* Clear index register */
FCCOBHI = 17; /* Program D-Flash command */
FCCOBLO = 0; /* High address word */
FCCOBIX++; /* Shift index register */
FCCOB = ru16_DflashAddress+DFLASH_Write_OFFSET; /* Low address word */
switch(Length)
{
case 2:
FCCOBIX++; /* Shift index register */
FCCOB = *ru16_Data; /* Load new data */
FSTAT = 128; /* Clear flag command complete */
break;

case 4:
FCCOBIX++; /* Shift index register */
FCCOB = *ru16_Data; /* Load new data */
FCCOBIX++; /* Shift index register */
FCCOB = *(ru16_Data+1); /* Load new data */
FSTAT = 128; /* Clear flag command complete */
break;

case 6:
FCCOBIX++; /* Shift index register */
FCCOB = *ru16_Data; /* Load new data */
FCCOBIX++; /* Shift index register */
FCCOB = *(ru16_Data+1); /* Load new data */
FCCOBIX++; /* Shift index register */
FCCOB = *(ru16_Data+2); /* Load new data */
FSTAT = 128; /* Clear flag command complete */
break;

case 8:
FCCOBIX++; /* Shift index register */
FCCOB = *ru16_Data; /* Load new data */
FCCOBIX++; /* Shift index register */
FCCOB = *(ru16_Data+1); /* Load new data */
FCCOBIX++; /* Shift index register */
FCCOB = *(ru16_Data+2); /* Load new data */
FCCOBIX++; /* Shift index register */
FCCOB = *(ru16_Data+3); /* Load new data */
FSTAT = 128; /* Clear flag command complete */
break;

default:
break;
}
//if ((FSTAT_FPVIOL == 1) || (FSTAT_ACCERR == 1))
// { /* Is protection violation or acces error detected ? */
// return ERR_NOTAVAIL; /* If yes then error */
// }
// while (!FSTAT_CCIF) {} /* Wait for command completition */
// if (FSTAT_MGSTAT)
// { /* Was attempt to write data to the given address errorneous? */
// return ERR_VALUE; /* If yes then error */
// }
/// return ERR_OK;
}

作者: 康桥人    时间: 2009-6-4 16:07

g3RCKQ9A.txt (3.64 KB)


上面有两段代码,肯定是好用的,但是有注意其是否执行完成,我用在OS里面的代码



附件: [求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞?] g3RCKQ9A.txt (2009-6-4 15:41, 3.64 KB) / 下载次数 198
http://bbs.eccn.com/attachment.php?aid=6945&k=6b835e47c62811629d943da3093f478f&t=1719828744&sid=814KlH
作者: Forest_Can    时间: 2009-8-13 21:46

我的邮箱:kyp82@163.com

Flash擦写程序你调好了吗?

我现在也在弄这个

能给我个例程吗?

非常感谢!


作者: 康桥人    时间: 2009-8-13 22:37

我也只能过Dflash的,你写P-Flash是用于bootloader的吗?
作者: slyang1314    时间: 2009-8-19 16:10

我也在找FLASH的例程,多谢你了!


作者: idly    时间: 2010-5-5 22:12

怎么没有读Flash的函数呢?




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0