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.

TMP1826: FLEXADDRESS command not working.

Part Number: TMP1826

Hello everyone,

i am currently writing a driver for the TMP1826. We want to use the flexible address to asign each TMP sensor a fixed address.
I am currently able to read the Temperatur of a single sensor(with the skip address command), read and write the Scratchpad-1 and set the address programmatically. But when i use FLEXADDRESS (0Fh) + address Byte instead of SKIPADDRESS i dont get any results on read.
I couldn´t find an example for the actual use of the FLEXADDRESS command in the TMP datasheet, so I was wondering what i am missing.

Hope you could guide me in the right direction, thanks.

  • Hi Paul,

    After you set the short address, does it read back as expected? Note that you must also set the appropriate FLEX_ADDR_MODE in Config 2, and that the state of the short address is only updated (in the case of HW modes) when there is a change to FLEX_ADDR_MODE bits.y

    FLEXADDR 0x0F is described in the flow chart Figure 9-20 where it's noted that byte is transmitted least significant bit first.

    ASCStudio has FLEXADDR support in the tmp1826.c sendAddr() function:

    /*
     *  ======== TMP1826_sendAddr ========
     *  Transmit the address portion of a OneWire transaction. 
     */
    void TMP1826_sendAddr(TMP1826_Handle sensor)
    {
        uint8_t i;
        
        if (sensor->addrMode == TMP1826_SKIP_ADDR) {
            /* this addrMode should only be used for single-device bus */
            mcu_txOneWireByte(sensor->busId, TMP1826_SKIP_ADDR);
        } else if (sensor->addrMode == TMP1826_FLEX_ADDR) {
            mcu_txOneWireByte(sensor->busId, TMP1826_FLEX_ADDR);
            mcu_txOneWireByte(sensor->busId, sensor->shortAddr);
        } else if (sensor->addrMode == TMP1826_MATCH_ADDR) {
            mcu_txOneWireByte(sensor->busId, TMP1826_MATCH_ADDR);
            for (i = 0; i < 8; i++){
                mcu_txOneWireByte(sensor->busId, sensor->devAddr >> (i*8));
            }
        } else if (sensor->addrMode == TMP1826_OVD_SKIP_ADDR) {
            /* this addrMode should only be used for single-device bus */
            mcu_txOneWireByte(sensor->busId, TMP1826_OVD_SKIP_ADDR);
            mcu_OneWireSetOverdrive(true);
        } else if (sensor->addrMode == TMP1826_OVD_MATCH_ADDR) {
            mcu_txOneWireByte(sensor->busId, TMP1826_OVD_MATCH_ADDR);
            for (i = 0; i < 8; i++){
                mcu_txOneWireByte(sensor->busId, sensor->devAddr >> (i*8));
            }
            mcu_OneWireSetOverdrive(true);
        }
    }

    Similarly, the example code for TI MCU on the TMP1826 product page has a similar sendDeviceAddress function in its tmp182x_func_driver.c

    //*****************************************************************************
    //
    // Helper Function: Sends device address as per the Address Mode
    //
    //*****************************************************************************
    void sendDeviceAddress(uint8_t uidevNo)
    {
        if(oneWireBus.AddrMode == 0)
        {
            mcu_txOneWireByte(SKIP_ADDR,oneWireBus.BusSpeed);
        }
        else if(oneWireBus.AddrMode == 1)
        {
            mcu_txOneWireByte(FLEX_ADDR,oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].acc_short_addr,oneWireBus.BusSpeed);
        }
        else
        {
            mcu_txOneWireByte(MATCH_ADDR,oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[0],oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[1],oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[2],oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[3],oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[4],oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[5],oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[6],oneWireBus.BusSpeed);
            mcu_txOneWireByte(tmp182x[uidevNo].devAddr[7],oneWireBus.BusSpeed);
        }
    
    }

    thanks,

    ren

  • Thank you for your answer. 
    I managed to find a mistake in the configuration.

    All solved now.