没有合适的资源?快使用搜索试试~ 我知道了~
MC9S08AW60子程序之FLASH
3星 · 超过75%的资源 需积分: 10 13 下载量 137 浏览量
2011-11-24
16:45:14
上传
评论
收藏 2KB TXT 举报
温馨提示
试读
3页
飞思卡尔单片机MC9S08AW60 C程序 FLASH例子
资源推荐
资源详情
资源评论
/*×Ó³ÌÐò*/
££i nclude <hidef.h> /* for EnableInterrupts macro */
££i nclude "derivative.h" /* include peripheral declarations */
#define Page_Erase PGM[21]=0x40; temp = ((unsigned char(*)(unsigned int))(PGM))
#define Program_Byte PGM[21]=0x20; temp = ((unsigned char(*)(unsigned int, unsigned char))(PGM))
//Array of opcode instructions of the Erase/Program in the HCS08 family
volatile unsigned char PGM[59] = {
0x87,0xC6,0x18,0x25,0xA5,0x10,0x27,0x08,0xC6,0x18,0x25,0xAA,0x10,0xC7,0x18,0x25,
0x9E,0xE6,0x01,0xF7,0xA6,0x20,0xC7,0x18,0x26,0x45,0x18,0x25,0xF6,0xAA,0x80,0xF7,
0x9D,0x9D,0x9D,0x9D,0x45,0x18,0x25,0xF6,0xF7,0xF6,0xA5,0x30,0x27,0x04,0xA6,0xFF,
0x20,0x07,0xC6,0x18,0x25,0xA5,0x40,0x27,0xF9,0x8A,0x81};
/* The opcode above represents this set of instructions
if (FSTAT&0x10){ //Check to see if FACCERR is set
FSTAT = FSTAT | 0x10; //write a 1 to FACCERR to clear
}
(*((volatile unsigned char *)(Address))) = data; //write to somewhere in flash
FSTAT = FSTAT | 0x80; //Put FCBEF at 1.
_asm NOP; //Wait 4 cycles
_asm NOP;
_asm NOP;
_asm NOP;
if (FSTAT&0x30){ //check to see if FACCERR or FVIOL are set
return 0xFF; //if so, error.
}
while ((FSTAT&0x40)==0){ //else wait for command to complete
;
}*/
void MCU_init(void)
{
/* ### Init_FLASH init code */
££i nclude <hidef.h> /* for EnableInterrupts macro */
££i nclude "derivative.h" /* include peripheral declarations */
#define Page_Erase PGM[21]=0x40; temp = ((unsigned char(*)(unsigned int))(PGM))
#define Program_Byte PGM[21]=0x20; temp = ((unsigned char(*)(unsigned int, unsigned char))(PGM))
//Array of opcode instructions of the Erase/Program in the HCS08 family
volatile unsigned char PGM[59] = {
0x87,0xC6,0x18,0x25,0xA5,0x10,0x27,0x08,0xC6,0x18,0x25,0xAA,0x10,0xC7,0x18,0x25,
0x9E,0xE6,0x01,0xF7,0xA6,0x20,0xC7,0x18,0x26,0x45,0x18,0x25,0xF6,0xAA,0x80,0xF7,
0x9D,0x9D,0x9D,0x9D,0x45,0x18,0x25,0xF6,0xF7,0xF6,0xA5,0x30,0x27,0x04,0xA6,0xFF,
0x20,0x07,0xC6,0x18,0x25,0xA5,0x40,0x27,0xF9,0x8A,0x81};
/* The opcode above represents this set of instructions
if (FSTAT&0x10){ //Check to see if FACCERR is set
FSTAT = FSTAT | 0x10; //write a 1 to FACCERR to clear
}
(*((volatile unsigned char *)(Address))) = data; //write to somewhere in flash
FSTAT = FSTAT | 0x80; //Put FCBEF at 1.
_asm NOP; //Wait 4 cycles
_asm NOP;
_asm NOP;
_asm NOP;
if (FSTAT&0x30){ //check to see if FACCERR or FVIOL are set
return 0xFF; //if so, error.
}
while ((FSTAT&0x40)==0){ //else wait for command to complete
;
}*/
void MCU_init(void)
{
/* ### Init_FLASH init code */
资源评论
- lzwaxck2015-06-11可以用,谢谢分享
- Leo_maoxiang2013-01-16你的程序有测试过吗 ,为什么不能用?!
sdfsxl
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功