大家好,
我现在用24lc256 eeprom. byte write/read 都没问题。
但是page write现在有问题,哪位大哥能帮忙一下,谢谢了
按照时序图,应该是以下7个步骤:
1) start bit
2) control byte + ACK
3) high address + ACK
4) low address + ACK
5) the first data + ACK
6) the second data and the third data, ......
7) the last data + ACK + stop bit
我现在想问一下,第6步中data byte 1 --- data byte 63 ,每个data之间需要ack吗?
我加ACK 和 不加ACK都试过,都不行,CLK在发送完第一个byte0后就没有了,不知道为什么,我并没有关闭i2c,并且因为是测试程序,所以只有i2c的代码,速度是100k
pReg[] 是对寄存器的操作,我是lpc2478的cpu
pReg[I2C_CONCLR] = (I2CONCLR_STAC|I2CONCLR_SIC|I2CONCLR_AAC);
pReg[I2C_CONSET] = I2CONSET_I2EN; //enable I2C as master
pReg[I2C_CONSET] = I2CONSET_STA; //send start condition
while(pReg[I2C_STAT] != 0x8);
pReg[I2C_DAT] = 0xA0; //set SLA+W:1010000+0
pReg[I2C_CONCLR] = (I2CONCLR_SIC|I2CONCLR_STAC); //clear SI bit to transmit SLA+W
while(pReg[I2C_STAT] != 0x18);
pReg[I2C_DAT] = highaddress; //write address to eeprom
pReg[I2C_CONCLR] = I2CONCLR_SIC; //clear SI bit to transmit address
while(pReg[I2C_STAT] != 0x28);
pReg[I2C_DAT] = lowaddress; //write address to eeprom
pReg[I2C_CONCLR] = I2CONCLR_SIC; //clear SI bit to transmit address
while(pReg[I2C_STAT] != 0x28); //stat must be 0x28
pReg[I2C_DAT] = *padr; //write data to eeprom
pReg[I2C_CONCLR] = I2CONCLR_SIC; //clear SI bit to transmit data
iLen--;
padr++;
do{
while(pReg[I2C_STAT] != 0x28); //stat must be 0x28
pReg[I2C_DAT] = *padr; //write data to eeprom
//pReg[I2C_CONCLR] = I2CONCLR_SIC; //clear SI bit to transmit data
iLen--;
padr++;
}while(iLen>0);
DelayMs(1,1); //wait to send data to eeprom
pReg[I2C_CONCLR] = I2CONCLR_SIC;
pReg[I2C_CONSET] = I2CONSET_STO; //set STO bit to stop transmit
DelayMs(1,2);