[sama5d27] Issues setting up TWI0 in at91bootstrap3

Moderator: nferre

smvoss
Posts: 6
Joined: Wed Sep 19, 2018 8:16 pm

[sama5d27] Issues setting up TWI0 in at91bootstrap3

Mon Mar 18, 2019 11:12 pm

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[] = {
		{"TWD0", AT91C_PIN_PC(27), 0, PIO_DEFAULT, PIO_PERIPH_E},
		{"TWCK0", AT91C_PIN_PC(28), 0, PIO_DEFAULT, PIO_PERIPH_E},
		{(char *)0, 0, 0, PIO_DEFAULT, PIO_PERIPH_A},
	};

	pio_configure(twi_pins);

	pmc_sam9x5_enable_periph_clk(AT91C_ID_TWI0);

	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

(void)twi_init()
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

at24_read()
with no success as well.
smvoss
Posts: 6
Joined: Wed Sep 19, 2018 8:16 pm

Re: [sama5d27] Issues setting up TWI0 in at91bootstrap3

Tue Mar 19, 2019 4:36 pm

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

Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 1 guest