Rand_Write_Eeprom(0,0X55);
a2b_test_data = Rand_Read_Eepeom(0);
//at24c16CËæ»úд
void Rand_Write_Eeprom(u16 data_addr,u8 data)
{
u8 ret ;
u8 addr ;
iic2key_Start();
iic2key_SendByte(0xA0);
ret = iic2key_Wait_Ack();
// addr = data_addr>>8;
// iic2key_SendByte(addr); //¼Ä´æÆ÷¸ßλ
// ret = iic2key_Wait_Ack();
addr = data_addr ;
iic2key_SendByte(addr); //¼Ä´æÆ÷µÍλ
ret = iic2key_Wait_Ack();
iic2key_SendByte(data);
ret = iic2key_Wait_Ack();
iic2key_Stop();
}
//AT24C16CËæ»ú¶Á
u8 Rand_Read_Eepeom(u16 data_addr)
{
u8 ret ;
u8 addr ;
u8 rec_data ;
iic2key_Start();
iic2key_SendByte(0xa0);
ret = iic2key_Wait_Ack();
// addr = data_addr>>8;
// iic2key_SendByte(addr); //¼Ä´æÆ÷¸ßλ
// ret = iic2key_Wait_Ack();
addr = data_addr ;
iic2key_SendByte(addr); //¼Ä´æÆ÷µÍλ
ret = iic2key_Wait_Ack();
iic2key_Start();
iic2key_SendByte(0xa1);
ret = iic2key_Wait_Ack();
rec_data = iic2key_RecvByte(1);
iic2key_Stop();
return rec_data ;
}
调用24C16C随机读写函数ACK都是正常的,但是读取的值一直是0XFF是怎么回事??
|