hello. I want use I2C program. so, I used twi_master_using_app_twi example. SDA is output only 1byte(0x21). I need to output a continuous 5byte. Where do I need to modify the part. thank you.
hello. I want use I2C program. so, I used twi_master_using_app_twi example. SDA is output only 1byte(0x21). I need to output a continuous 5byte. Where do I need to modify the part. thank you.
your length is set to what number? you get the first or the last byte?
#define DATA_ARRAY_LEN 10 uint8_t data[DATA_ARRAY_LEN] = {0x40, 0xC0, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x88}; #define MMA7660_ADDR (0x98U >> 1)
err_code = nrf_drv_twi_tx(&m_twi_mma_7660, MMA7660_ADDR, data, DATA_ARRAY_LEN, true);
APP_ERROR_CHECK(err_code);
I get one byte is link address as below. blog.naver.com/.../220723715390 SCLK is 9byte. is it right? please confirm it.
Hi,
On the image in your comment you are sending a 7 bit address (0x98 >> 1) with a write bit. You also get a Not Acknowledge (NACK) bit in the end. The 9th bit on the SCK is for the NACK bit.
Read about NACK and addresses in the I2C spec here: I2C Bus Specification. Read about the difference between 8 and 7 bits addresses and why you right shift some addresses here.
The NACK you get is important to note. It signifies that you are trying to transfer a byte, but no slave is responding. This is often due to one of the following reasons:
thank you for your support. I want master communication. so, set 0x98>>1 with a write bit. I wrong master address? SCK and SDA pin is right.
You need 8 bits to write 0x98 (b1001 1000) and the drivers expect a 7 bit address. Hence we can definitely say that you need to right shift the address 1 bit as you do. The drivers will take care of assembling the 7 bit address and the R/W bit. This means that as far as I can see you are doing everything right with regards to the address and R/W bit. What kind of slave do you use? What is the part number? Are you sure it has power?