EmbeddedRelated.com
Forums

Problem reading eeprom on AT91SAM7S-EK

Started by Gabriele Brosulo September 13, 2007
Hi all,
trying to read an i2c eeprom, my code loop in the following while:



Led 2 and 3 are on, so it means that

!(status & AT91C_TWI_RXRDY) == false

Or I'm wrong? But Led 1 go on, and never go off, so it means that the code is
looping through the while.. What's the issue? I'm wrong, or the compiler goes
wrong?

Thanks all

--
g4b0, linux user n. 369000
http://gabo.homelinux.com
Gabriele, Comments Interspersed..
--- In A..., Gabriele Brosulo wrote:
>
> Hi all,
> trying to read an i2c eeprom, my code loop in the following while:
>
>
>
> Led 2 and 3 are on, so it means that
>
> !(status & AT91C_TWI_RXRDY) == false
>
> Or I'm wrong? But Led 1 go on, and never go off, so it means that
the code is
> looping through the while.. What's the issue?

Basically, there is SOME bit set in TWI_SR, but it isn't RXRDY.

>
> Thanks all
>
> --
> g4b0, linux user n. 369000
> http://gabo.homelinux.com
>
Hi, sorry for the late, but I was busy on another project.. I have to work in
timesharing, now the schduler is back to my AT91SAM :)

On Friday 14 September 2007 15:44:24 twgbonehead wrote:
> Gabriele, Comments Interspersed..
>
> --- In A..., Gabriele Brosulo wrote:
> > Hi all,
> > trying to read an i2c eeprom, my code loop in the following while:
> >
> > [code]
> > pPIOA->PIO_CODR = LED1; // turn LED on
> >
> > while (!(status & AT91C_TWI_RXRDY)){
>
> (I hope you initialized status (i.e. to 0) before this! This might
> have been better in a do{} while construct.

I followed your suggestion, now my code is:

pPIOA->PIO_CODR = LED1; // turn LED on

/* Wait until RXRDY is high to read the next data */
do {
status = AT91C_BASE_TWI->TWI_SR;
} while (!(status & AT91C_TWI_RXRDY));

pPIOA->PIO_SODR = LED1; // turn LED off

I removed every delay and I just wait for the RXRDY bit to become high, but it
never does it!!!

Pheraps I miss somethings during initialization, if you want I can post all
the related code.. It can also be an hardware error, but it's not my issue,
and is it's the second option I've got to demonstrate it to my hardware
guys...

Thanks for your time

--
g4b0, linux user n. 369000
http://gabo.homelinux.com