Tool/software:
Hi,
I am able to read data from the scratchpad2 when I write into scratchpad just before but can not able to read data from the EEPROM.
Is it possible to read data from the EEPROM? if yes, please do provide the sample code or flow chart for that
Below is the code which i am currently unable to read the data from the EEPROM: Please let me now if I am missing something?
/// sp2 write sequence
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 18750);
oneWireReset();
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 115200);
//wait
mcu_txOneWireByte(0xCC);
mcu_txOneWireByte(0x0F);
mcu_txOneWireByte(0x00); // high address
mcu_txOneWireByte(0x00); // low address
mcu_txOneWireByte(0x00);
mcu_txOneWireByte(0x04);
mcu_txOneWireByte(0x03);
mcu_txOneWireByte(0x02);
mcu_txOneWireByte(0x6F);
mcu_txOneWireByte(0x01);
mcu_txOneWireByte(0x0e);
mcu_txOneWireByte(0x00);
rom_code[37] = OneWire_ReadByte(); //crc
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 18750);
oneWireReset();
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 115200);
//wait
//read scratchpad2
mcu_txOneWireByte(0xCC);
mcu_txOneWireByte(0xAA);
mcu_txOneWireByte(0x00); // high address
mcu_txOneWireByte(0x00); // low address
rom_code[38] = OneWire_ReadByte();
rom_code[39] = OneWire_ReadByte();
rom_code[40] = OneWire_ReadByte();
rom_code[41] = OneWire_ReadByte();
rom_code[42] = OneWire_ReadByte();
rom_code[43] = OneWire_ReadByte();
rom_code[44] = OneWire_ReadByte();
rom_code[45] = OneWire_ReadByte();
rom_code[46] = OneWire_ReadByte(); //crc
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 18750);
oneWireReset();
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 115200);
//wait
// copy into scratchpad and EEPROM
mcu_txOneWireByte(0xCC);
mcu_txOneWireByte(0x55);
mcu_txOneWireByte(0xA5);
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 18750);
oneWireReset();
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 115200);
//wait
//match address
mcu_txOneWireByte(0x55);
mcu_txOneWireByte(0x27);
mcu_txOneWireByte(0x00);
mcu_txOneWireByte(0x00);
mcu_txOneWireByte(0x00);
mcu_txOneWireByte(0x00);
mcu_txOneWireByte(0x23);
mcu_txOneWireByte(0x67);
mcu_txOneWireByte(0x13);
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 18750);
oneWireReset();
hal_uart_close(UART_2_INDEX);
hal_uart_changeBaudRate(UART_2_INDEX, 115200);
//read from EEPROM
mcu_txOneWireByte(0xCC);
mcu_txOneWireByte(0xF0);
mcu_txOneWireByte(0x00); // high address
mcu_txOneWireByte(0x0); // low address
rom_code[28] = OneWire_ReadByte();
rom_code[29] = OneWire_ReadByte();
rom_code[30] = OneWire_ReadByte();
rom_code[31] = OneWire_ReadByte();
rom_code[32] = OneWire_ReadByte();
rom_code[33] = OneWire_ReadByte();
rom_code[34] = OneWire_ReadByte();
rom_code[35] = OneWire_ReadByte();
rom_code[36] = OneWire_ReadByte(); //crc