TWI driver ASF question about some functions

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

Posts: 13
Joined: Mon May 25, 2015 8:00 pm

TWI driver ASF question about some functions

Tue Dec 08, 2015 12:17 pm

Hi all,

I've recently used TWI driver, driver and I2C works in master mode but I've found some problems:

- void twi_write_byte(Twi *p_twi, uint8_t uc_byte) is not working, using a signal analyzer I see 8 bits of clock, but data is always 0 with a ACK high at the end(ACK it's normal, but data should not be 0).

- In twi_master_write and twi_master_read I provide an 8 bit address that is shifted by one and added a final bit 1 or 0 if it's read or write. Bitshift is working as expected in twi_master_write, but in twi_master_read I've always a 0 at the end of the address like in twi_master_write. Why is not set to 1?

- In struct twi_packet there is an array address[2] and chip, chip is I2C address of the chip, but what is it address? It is a register address of slave device? and, what use have this array when I'm reading a packet from slave?

I've performed a test with twi_packet and twi_master_read, and I've set the first byte of address array and set array size (addr_length) to 1, my reading packet size was 1 byte and I've set packet size (length) to 1. In communication I've read the 1 byte chip address, 1 byte address and 2 byte packet. But I should have 1 byte packet and not 2, and also recived data wasn't written to my variable(was not saved as happen when I set address lenght to 0). Can someone explain becouse adding 1 address I read 2 bytes instead of 1 byte?

Thank you!
Posts: 11
Joined: Mon Sep 07, 2015 4:18 am

Re: TWI driver ASF question about some functions

Mon Dec 14, 2015 5:39 am

Maybe I encounter this , too. I use the SAMV71XPLAINED board and the example the asf provided, I find that the twihs_master_write always transmits failed. I can just only catch the address signal but there is no data flows.

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 2 guests