- 1. 分字节写,分字节謮
- ulong Temp = 0xA5B6C7D8;
- //write**************
- IapProgramByte(0x0200, (uchar)(Temp >>24));
- IapProgramByte(0x0201, (uchar)(Temp >>16));
- IapProgramByte(0x0202, (uchar)(Temp >>8));
- IapProgramByte(0x0203, (uchar)(Temp));
- //Read***************
- Temp = 0x00;
- Temp |= (ulong)IapReadByte(0x0200)<<24;
- Temp |= (ulong)IapReadByte(0x0201)<<16;
- Temp |= (ulong)IapReadByte(0x0202)<<8;
- Temp |= (ulong)IapReadByte(0x0203);
- 2. 用联合体
- typedef union{
- uchar u8_dat[4];
- ulong u32_Dat;
- }union32;
- union32 union_Dat;
- ulong Temp = 0xA5B6C7D8;
- //write**************
- union_Dat.u32_Dat = Temp;
- IapProgramByte(0x0200, union_Dat.u8_dat[0]);
- IapProgramByte(0x0201, union_Dat.u8_dat[1]);
- IapProgramByte(0x0202, union_Dat.u8_dat[2]);
- IapProgramByte(0x0203, union_Dat.u8_dat[3]);
- //Read***************
- union_Dat.u8_dat[0] = IapReadByte(0x0200);
- union_Dat.u8_dat[1] = IapReadByte(0x0201);
- union_Dat.u8_dat[2] = IapReadByte(0x0202);
- union_Dat.u8_dat[3] = IapReadByte(0x0203);
- Temp = union_Dat.u32_Dat;
复制代码 |