xiaoxiaoer :
我现在发现一个读写QG8的新的Flash程序,非常好用,不必象GP32那样,我在QG8单凭机调试过了没问题的,直接拷贝过来就可以用,真是简单,而且代码简洁!
#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 function 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};
void main(void) {
unsigned char temp,i;
MCU_init();
/* include your code here */
temp = Page_Erase(0xF000);
if(temp==0xFF){
PTAD=0;
}
for(i=0; i<= 255; i++) {
temp = Program_Byte(0xF000+i,i);
if(temp==0xFF){
PTAD=0;
}
}
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */ |