This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMP1827: Read EEPROM data and scratchpad from TMP1827

Part Number: TMP1827

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

  • When sending the COPY_SP2 command (0x55 0xA5,) it's necessary to wait 21ms for the EEPROM operation to complete. Your code  resets the device immediately after sending the copy command.

    /*
     *  ======== TMP1826_writeEEPROM ========
     *  Write data to 2Kbit user EEPROM in 8 byte chunks
     */
    void TMP1826_writeEEPROM(TMP1826_Handle sensor, uint8_t address, uint8_t *data)
    {
        uint8_t i;
        uint8_t txBuf[11];
    
        /* prepare data for transmit and CRC */
        txBuf[0] = 0;
        txBuf[1] = address;
        for (i = 0; i < 8; i++){
            txBuf[i+2] = data[i];
        }
    
        /* transmit data */
        mcu_txOneWireReset(sensor->busId);
        TMP1826_sendAddr(sensor);
        mcu_txOneWireByte(sensor->busId, TMP1826_WRITE_SP2);
        for (i = 0; i < 10; i++){
            mcu_txOneWireByte(sensor->busId, txBuf[i]);
        }
        txBuf[10] = mcu_rxOneWireByte(sensor->busId);
    
        /* crcFail will be 0 for successful CRC */
        sensor->crcFail = TMP1826_crc(txBuf, 11);
    
        /* transmit  commit to eeprom command */
        mcu_txOneWireReset(sensor->busId);
        TMP1826_sendAddr(sensor);
        mcu_txOneWireByte(sensor->busId, TMP1826_COPY_SP2);
        mcu_txOneWireByte(sensor->busId, 0xA5);
        /* Wait for copy time (13ms typ, 21ms max) */
        mcu_msWait(21);
    }

    thanks,

    ren