This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWI, Always get ANACK error?

Hi, when trying to read a register from a chip using the IIC interface,blocking mode:

uint32_t ms5837_cmd_read(uint8_t *data, uint8_t length, uint8_t register_address)
{
uint32_t err_code;
err_code = nrf_drv_twi_tx(&m_twi_ms_5837, MS5837_TWI_ADDR, &register_address ,  1, true);



if (NRF_SUCCESS == err_code)
	
   err_code = nrf_drv_twi_rx(&m_twi_ms_5837, MS5837_TWI_ADDR, data, length, false);
		
	
APP_ERROR_CHECK(err_code);
	return err_code;	
}			

I always get the "enternal error", 0x03.

I looked up the register and found this:

image description

As you can see, there is an ANACK error, suggesting there isn't an ACK after address write.

What should I do to solve this???

Help!!!!

@endnode can you please provide a little insight?

Parents
  • Hi, no problem: here you go:https://imgur.com/a/J6bT4

    As you can see, the clock, after sending the cmd/target register address, stays low for some reason... based on my limited knowledge, it should go high, together with a high SDA, they make up the "stop condition".

    Edit: Oh, this is the reset command. You can see that the first command was responded to properly, the 9th bit was a low.

    Also after sending these 2 9 bit data, the ERROR SRC register is 0, suggesting everything went well.

    And then if I try to read registers (the transaction above was a reset sequence, required to interact with this chip), I can send just fine, but when it comes to read, the slave will not respond at all after the slave device address (not register address, it was already sent prior to the read, you know, tx first, rx later). I'll see if I can capture that wave form too and post it here.

Reply
  • Hi, no problem: here you go:https://imgur.com/a/J6bT4

    As you can see, the clock, after sending the cmd/target register address, stays low for some reason... based on my limited knowledge, it should go high, together with a high SDA, they make up the "stop condition".

    Edit: Oh, this is the reset command. You can see that the first command was responded to properly, the 9th bit was a low.

    Also after sending these 2 9 bit data, the ERROR SRC register is 0, suggesting everything went well.

    And then if I try to read registers (the transaction above was a reset sequence, required to interact with this chip), I can send just fine, but when it comes to read, the slave will not respond at all after the slave device address (not register address, it was already sent prior to the read, you know, tx first, rx later). I'll see if I can capture that wave form too and post it here.

Children
No Data
Related