EmbDev.net

Forum: ARM programming with GCC/GNU tools i2c driver on AT91SAM7S-EK (using FreeRTOS)


Author: Gabriele Brosulo (g4b0)
Posted on:

Rate this post
0 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

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 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

Author: Marcelo adrian Lorenzati sanz (Company: sistemasembebidos.com.ar) (darukur)
Posted on:

Rate this post
0 useful
not useful
If you are interested I developed a few FreeRTOS driver for AT91SAM7 
(I2S, SPI, FAT, etc) if you are interested you can check it at:

http://sistemasembebidos.com.ar/foro/?topic=727.0

Is a spanish spoken forum but the code is fully commented in english

Regards,

Marcelo

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.