- UID
- 342093
- 性别
- 男
|
型号:HC908JL16.晶振20M
主要程序程序如下:
#define ERARNGE 0xFCBE
#define PRGRNGE 0xFC06
#define LDRNGE 0xFF30
const byte FLBPR_INIT @0x0000FFCF = 0xFE;
unsigned char BUS_SPD @0x0060; /* Value should equal 4x Bus speed */
unsigned char DATASIZE @0x0061; /* Number of bytes in data array (max 255) */
unsigned int ADDR @0x0062; /* Start address of FLASH to manipulate */
unsigned char DATA[4] @0x0064; /* Data to program into FLASH */
unsigned int *FILE_PTR = (unsigned int *)(&BUS_SPD);
uchar shezhi[4] @0x6c; //FLASH保存变量
CONFIG1=0X19; //COP=DISABLE stop=disable
void write_flash(uint adr,uchar dates){
uchar i; //写数据到FLASH
asm sei;
BUS_SPD =20;
DATASIZE =dates;
ADDR = adr;
for(i=0;i
DATA=shezhi;
asm(LDHX FILE_PTR);
asm(JSR PRGRNGE);
asm cli;
}
void FLASHErase(uint adr){
unsigned char i;
asm sei;
BUS_SPD = 20;
DATASIZE = 4;
ADDR = adr;
for(i=0;i<4;i++)
DATA=0xaa;
asm(LDHX FILE_PTR);
asm(JSR ERARNGE);
asm cli;
}
现在的问题是,程序刚开始运行时,读写FLASH都正常,但进入主程序循环后,我里面有一个时间中断,好象是在这个中断起作用后,就读写不了了,而且一擦除就卡死.老大帮忙看看..
|
|