void isp_disable() // 关闭 ISP { ISP_CONTR = 0x00; // ISP_ADDRL = 0x00; ISP_ADDRH = 0x00; ISP_CMD = 0x00; ISP_TRIG = 0x00; } //------------ void read_eprom(uint address) // 读EPROM { uchar i_data; ISP_CONTR = 0x83; ISP_ADDRL = address; address >>= 8; ISP_ADDRH = address; ISP_CMD = 0x01; ISP_TRIG = 0x46; ISP_TRIG = 0xb9; /**/ i_data = ISP_DATA ; isp_disable(); return(i_data); } //------------ void write_eprom(uint address,uchar write_data) { ISP_DATA = write_data ; ISP_CONTR = 0x83; // ISP_ADDRL = address ; ISP_ADDRH = address>>8; ISP_CMD = 0x02; ISP_TRIG = 0x46; ISP_TRIG = 0xb9; /**/ isp_disable(); } //------------ void clr_eprom (uint address) //扇区擦除。 { ISP_CONTR = 0x83; // ISP_ADDRL = address ; ISP_ADDRH = address>>8 ; ISP_CMD = 0x03; ISP_TRIG = 0x46; ISP_TRIG = 0xb9; /**/ isp_disable(); } |