i2c driver on AT91SAM7S-EK (using FreeRTOS)

OP #1172792
Rate this post
useful
not useful
Hi all,

I'm trying to use a eeprom with my evaluation board (the one in the
subject),
so I added the code from the atmel site (AT91-AN01: Using the Two-wire
interface (TWI) in Master Mode on AT91SAM Microcontrollers) to my
adjusted
version of FreeRTOS.

In order to make things working, I have added lib_AT91SAM7S256.h to my
project. This header is a set of inline functions useful to initialize
and
use the processor, without directly use the processor register.

It does compile, but the problem now is that the example code downloaded
from Atmel site stops working during the execution of
AT91F_AT24C_WritePage(). It loop forever just here (into the while):

[..snip..]

 /* Send the buffer to the page */
for ( Count=0; Count < NumOfBytes ;Count++ )
{
____AT91C_BASE_TWI->TWI_THR = *Buffer++;

____/* Wait until TXRDY is high to transmit the next data */
____status = AT91C_BASE_TWI->TWI_SR;
____while (!(status & AT91C_TWI_TXRDY))  <---- it loops here
____status = AT91C_BASE_TWI->TWI_SR;
}

[..snip..]

It seems that AT91C_TWI_TXRDY (or AT91C_BASE_TWI->TWI_SR) never becomes
0, but I can't wonder whi..

Anybody known the solution?

Thanks a lot
g4b0
#1172793
Rate this post
useful
not useful
Gabriele Brosulo wrote:
> It seems that AT91C_TWI_TXRDY (or AT91C_BASE_TWI->TWI_SR) never becomes
> 0, but I can't wonder whi..

Actually the while loop continues while the TXRDY bit is zero. It is
waiting for it to become one not zero. (as per flowchart on page 14 of
the app. note). However beyond helping you understand the meaning of the
code it is not possible to say what the problem is from that snippet.
You have called AT91F_TWI_Open() prior to this I presume?

Clifford

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now