Tool/software:
hi,
I am able to write data via scratchpad-2 but when I am trying to read the data from EEPROM after restarting the device the data received is always 0xFF.
Can you help us if we are missing something while reading the data from EEPROM?
my code is mentioned below:
// 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
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
mcu_txOneWireByte(0xCC);
mcu_txOneWireByte(0x55);
mcu_txOneWireByte(0xA5);
// 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(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);
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
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
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
mcu_txOneWireByte(0xCC);
mcu_txOneWireByte(0x55);
mcu_txOneWireByte(0xA5);
// 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(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);
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