PSOC3/5 EEPROM 書き込み、読み出し
PSOC3,PSOC5のEEPROM書き込み方void eeprom_test(void){uint8 dat[16];uint16 c;uint8 d;device_memory[128]; //EEPROM Write(0は列0~15書き込み指定) CYGlobalIntDisable //CPU ALL Interrupt Disable d = EEPROM_1_Write(dat,0); //EEPROM write (16byte write) (0 = 列0-15 write) CYGlobalIntEnable; //CPU Interrupt ALL Enable //例 CYGlobalIntDisable //CPU ALL Interrupt Disable d = EEPROM_1_Write(dat,1); //EEPROM write (16byte write)(1 = 列15-31 write) d = EEPROM_1_Write(dat,2); //EEPROM write (16byte write)(2 = 列32-47 write) d = EEPROM_1_Write(dat,3); //EEPROM write (16byte write)(3 = 列48-63 write) CYGlobalIntEnable; //CPU Interrupt ALL Enable 注意:書き込み時割り込み禁止にする。 //EEPROM Read(列0~127読み出し) for(c = 0; c < 128; c++){ device_memory[c] = CY_GET_REG8(CYDEV_EE_BASE + c); //EEPROM read } //例 EEPROM Read(列128~255読み出し) for(c = 0; c < 128; c++){ device_memory[c] = CY_GET_REG8(CYDEV_EE_BASE + 128 + c); //EEPROM read } 注意:読み出しは1バイトでもOK。}//1バイト書き込みの方法void eeprom_one_write(uint8 row,uint8 nob,uint8 d) //EEPROM one data write{uint8 c;uint8 s;uint8 dat[16]; //EEPROM data read for(c = 0; c < 16; c++){ dat[c] = CY_GET_REG8(CYDEV_EE_BASE + (row * 16) + c); //EEPROM data read } dat[nob] = d; //EEPROM data write s = EEPROM_1_Write(dat,row); //EEPROM data write 説明:row=列番号(16バイト単位)、nob=何番目、d=data) 1バイト書き込みは16バイト読み出し後、そのデータを変更して書き込みます。}