unsigned short int read_flash_word(unsigned short int addr) {unsigned char ss; FEEMOD =0x00; //关闭页面,禁止修改 FEEADR = addr; // set address FEECON = 0x01; // single read command flash_error = 0x00; ss = FEESTA&0x01; while (!ss && (flash_error++<=2000)) ss = FEESTA&0x01; // wait data read ready return(FEEDAT); // one byte data }
void write_flash_word(unsigned short int addr, unsigned short int *word, unsigned short int count) { unsigned short int erased_page, i; unsigned char ss; erased_page = 0x01; //页面起始地址的低九位应该为0,设置为1表示开始就需要页面清空 for(i=0; i<count; i++) { if (erased_page!=(addr&0xFE00)) { Erase_Page(addr); erased_page = addr&0xFE00; } FEEADR = addr++; addr++; // set address //地址必须 “+ 2” FEEDAT = *word; word++; // set data value FEECON = 0x02; // write command flash_error = 0x00; ss = FEESTA&0x01; while (!ss && (flash_error++<=2000)) ss = FEESTA&0x01; // wait data read ready } FEEMOD =0x00; //关闭页面,禁止修改 }
执行写程序,程序就飞了,中断也不执行了,求教! |