NRF_ERROR_DRV_TWI_ERR_ANACK ?

Dear Members,

I want to use MAX17048 and getting thiis message  :

<error> app: ERROR 33281 [NRF_ERROR_DRV_TWI_ERR_ANACK] at ..\..\..\MAX17048.c:71

void MAX17048_init_i2c(uint32_t scl, uint32_t sda)
{
        _i2caddr = MAX17048_WRITE_ADDR;
        twi_master_init(scl, sda);
}

//Init MAX17048
       MAX17048_init_i2c(MAX17048_CONFIG_SCL_PIN, MAX17048_CONFIG_SDA_PIN);
      MAX17048_write();

TWI code :

 uint8_t buffer[3] = {0xFE,0x54,0x00};
                    
        ret = nrf_drv_twi_tx(&m_twi_master, 0x6C, buffer, sizeof(buffer), false);
              APP_ERROR_CHECK(ret);

I have others I2C Devices, SSD1306 and 24C16 and they are initialized before this chip,

Any clues,

Thanks

Parents
  • The address is 0x36,

    ////////////////////////////////
    #define MAX1704x_ADDRESS 0x36 // Unshifted I2C address. Becomes 0x6C for write and 0x6D for read.

  • I wrote for WRITE :

    //WRITE TO 0xFE REGISTER ON MAX17408 (CMD) BEGIN
                      buffer_tx[0] = 0xFE;
                        buffer_tx[1] = 0x54;
                        buffer_tx[2] = 0x00;
                    ret = nrf_drv_twi_tx(&m_twi_master_MAX17048, 0X36, buffer_tx, 3, false);   

    how can I write for READ ?

  • Hello again, Rixtronixlab

    Great - I am glad to see that the devices are showing up in the scanner (so we know there is no hardware issues), and that you have found the right addresses for your device!

    RixtronixLAB said:
    I wrote for WRITE :
    RixtronixLAB said:
    how can I write for READ ?

    I would recommend that you make use of the nrf_drv_twi_xfer function in combination with the NRF_DRV_TWI_XFER_DESC_TX and _RX transfer descriptors, instead of the deprecated nrf_drv_twi_tx and _rx functions with manually loaded packets, for your transfers. The nrf_drv_twi_xfer function gives you a lot more functionality easily accessible (see the different FLAGS descriptions), compared to the deprecated versions.

    If you would still like to use the deprecated functions you could see their usage demonstrated in the twi_sensor example.

    Are you creating your device's driver from scratch, or are you basing it on an existing driver for the device?
    Usually, the header file of provided drivers will include all the registers as #defines, with a different name for read and write of the same register - since the values are different. This is a usual way to do it, in order to avoid manually having to add the read write bit, and to avoid confusion.

    Best regards,
    Karl

Reply
  • Hello again, Rixtronixlab

    Great - I am glad to see that the devices are showing up in the scanner (so we know there is no hardware issues), and that you have found the right addresses for your device!

    RixtronixLAB said:
    I wrote for WRITE :
    RixtronixLAB said:
    how can I write for READ ?

    I would recommend that you make use of the nrf_drv_twi_xfer function in combination with the NRF_DRV_TWI_XFER_DESC_TX and _RX transfer descriptors, instead of the deprecated nrf_drv_twi_tx and _rx functions with manually loaded packets, for your transfers. The nrf_drv_twi_xfer function gives you a lot more functionality easily accessible (see the different FLAGS descriptions), compared to the deprecated versions.

    If you would still like to use the deprecated functions you could see their usage demonstrated in the twi_sensor example.

    Are you creating your device's driver from scratch, or are you basing it on an existing driver for the device?
    Usually, the header file of provided drivers will include all the registers as #defines, with a different name for read and write of the same register - since the values are different. This is a usual way to do it, in order to avoid manually having to add the read write bit, and to avoid confusion.

    Best regards,
    Karl

Children
No Data
Related