求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞?
- UID
- 790434
- 性别
- 男
|
求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞?
本帖最后由 xuh5156 于 2011-7-21 10:27 编辑
<p>求助:谁用过MC9S12P128芯片,有关该芯片的Flash的擦写怎么搞?> |
|
|
|
|
|
- UID
- 781716
- 性别
- 男
|
我用过,而且写了擦写程序。再擦写P-FLASH的时候,总是遇到问题,也就是你单步执行可以擦写,但是一自由运行就跑飞。有的时候还出现复位的情况,TARGET SELF-RESET DETECED,我注意到了延时的问题,还有编程电压的问题。但还是没办法解决。擦写D-FLASH的时候就没有问题。不知道你现在问题解决了没有?我用的是S12XS128的芯片写的程序,以后我们要用S12P的芯片替换。我看了一下S12P的数据手册,关于FLASH的擦除基本上与S12XS一样的。你可以参考一下。并帮助我解决一下问题。 |
|
|
|
|
|
- UID
- 781716
- 性别
- 男
|
|
|
|
|
|
- UID
- 187580
- 性别
- 男
|
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; }
|
个人BLOG:http://blog.eccn.com/u/107300/index.htm |
|
|
|
|
|
- UID
- 187580
- 性别
- 男
|
g3RCKQ9A.txt (3.64 KB)
上面有两段代码,肯定是好用的,但是有注意其是否执行完成,我用在OS里面的代码 |
个人BLOG:http://blog.eccn.com/u/107300/index.htm |
|
|
|
|
|
- UID
- 795334
- 性别
- 男
|
我的邮箱:kyp82@163.com Flash擦写程序你调好了吗? 我现在也在弄这个 能给我个例程吗? 非常感谢! |
|
|
|
|
|
- UID
- 187580
- 性别
- 男
|
我也只能过Dflash的,你写P-Flash是用于bootloader的吗? |
个人BLOG:http://blog.eccn.com/u/107300/index.htm |
|
|
|
|
|
- UID
- 796871
- 性别
- 女
|
|
|
|
|
|
- UID
- 810705
|
|
|
|
|
|