This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Always getting NCK.

Hi,

I'm trying to control LSM6DS3 by TWI communication. Slave address of the chip is 0xD4 when SDO/SA0 pin is low.

I'm using SDK13.0.0.

My code is like below.

ret_code_t err_code;

uint8_t flag=0;
uint8_t *LSM_DATA;

err_code = twi_init();
APP_ERROR_CHECK(err_code);

while (true)
{
	twi_test();
	nrf_delay_ms(100);
	flag = 0;
}

twi_init()

ret_code_t err_code;
	
const nrf_drv_twi_config_t twi_config = {
   .scl                = 4,
   .sda                = 3,
   .frequency          = NRF_TWI_FREQ_100K,
   .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
   .clear_bus_init     = false
};
	err_code = nrf_drv_twi_init(&m_twi_master, &twi_config, NULL, NULL);
	nrf_drv_twi_enable(&m_twi_master);
	return err_code;

twi_test()

ret_code_t err_code;

uint8_t slv_addr = 0xD4>>1;
uint8_t temp1 = 0x12;
uint8_t temp3[2] = {temp1, 0x00};

err_code = nrf_drv_twi_tx(&m_twi_master, slv_addr, temp3, sizeof(temp3), false);
return err_code;

It is almost similar to example code.(twi_sensor_pca10040) But I don't know why always NCK.

I checked hardware and TWI timing diagram and is correct.

Any help is greatly appreciated.

==========================================================================================

Oscilloscope capture image

image description image description image description image description

Parents Reply Children
No Data
Related