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
  • Follow up: Stranger things... I dunno if it was caused by the fact that the reset sequence was a failure, but after some delay, required by the datasheet of the slave device, and I try to read its register, the master, my nrf51822 that is, sends only target register in the first step/ TX - which prompts me to suspect that maybe nrf51822 think its a continuation of last transaction? Or in other words, I must manually code nrf51822 for it to know a session has ended, and at the same time, it sends the proper stop condition? Anyway, here's the tx wave, the first step of the 2 steps:

    https://imgur.com/a/D0Nu9

    And the errorcode is 0, which suggests it is successful. This is really weird but since the 9th bit was a low, it isn't all that weird?...

Reply
  • Follow up: Stranger things... I dunno if it was caused by the fact that the reset sequence was a failure, but after some delay, required by the datasheet of the slave device, and I try to read its register, the master, my nrf51822 that is, sends only target register in the first step/ TX - which prompts me to suspect that maybe nrf51822 think its a continuation of last transaction? Or in other words, I must manually code nrf51822 for it to know a session has ended, and at the same time, it sends the proper stop condition? Anyway, here's the tx wave, the first step of the 2 steps:

    https://imgur.com/a/D0Nu9

    And the errorcode is 0, which suggests it is successful. This is really weird but since the 9th bit was a low, it isn't all that weird?...

Children
No Data
Related