Page 1 of 1

[sama5d27] Issues setting up TWI0 in at91bootstrap3

Posted: Mon Mar 18, 2019 11:12 pm
by smvoss
I'm having issues while attempting to setup TWI0 for the sama5d27, using at91bootstrap3.

This interface works just fine in u-boot, and now I'm attempting to get it setup in bootstrap. I am using PC27 for TWD0 (mux E) and PC28 for TWCK0 (mux E).

This seems pretty straight forward, here is my code:

Code: Select all

unsigned int at91_twi0_hw_init(void)
	unsigned int base_addr = AT91C_BASE_TWI0;

	const struct pio_desc twi_pins[] = {
		{(char *)0, 0, 0, PIO_DEFAULT, PIO_PERIPH_A},



	return base_addr;

However, when attempting to actually use this device, I always get the same result: "twi read: timeout to wait RXRDY bit".

The sequence of using the twi device has been pretty trivial, call

Code: Select all

and then

Code: Select all

ret=twi_read(0, 0x54, 0, 1, buffer, 4)
to attempt to read 4 bytes into buffer. As the device on the other side is an EEPROM (at24xx) I also tried the at24xx driver, and using

Code: Select all

with no success as well.

Re: [sama5d27] Issues setting up TWI0 in at91bootstrap3

Posted: Tue Mar 19, 2019 4:36 pm
by smvoss
I ended up getting this to work, but couldn't edit the post as it was "in review" and I have no way of seeing it once it enters that state. Turns out, by default the act8865 was being enabled and being used, which was raising an error since that device did not exist, causing the init to stop early which looked like my twi device. After making sure that device was disabled in the defconfig (as it is not a selectable option in menuconfig), it skipped that code and allowed mine to setup successfully