Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problem with AT91SAM7S256, SPI and DMA
PostPosted: Thu Oct 08, 2009 10:36 pm 
Offline

Joined: Wed Oct 17, 2007 10:07 am
Posts: 3
I have a problem using DMA with SPI. I am supposed to start an SPI
transaction via DMA, wait for an interrupt to trigger once the DMA is
done with, and finally start over. I am using the ENDRX flag in SPI_SR
to trigger the interrupt. The transactiocs are 1-6 bytes long.

The problem is that the interrupt gets triggered as soon as I start the
transaction. It seems that the ENDRX flag gets set immediately and when
I then exit the interrupt, I will get back to it again and again, until
I disable it.

In the case that revealed this problem, I am trying to receive three
bytes. I start that transaction in the interrupt and the interrupt
finishes when 18 bits out of 24 have been received. Then there is only
some constant delay between the interrupts and the same interrupt gets
triggered again when there are four more bits to be received. My
oscilloscope reveals that those remaining bytes get clocked in but the
never end up in the buffer.

This is how I start the DMA transaction:
SPI_RPR = pointer_to_rx_buffer;
SPI_TPR = pointer_to_tx_buffer;
SPI_RCR = amount_of_bytes;
SPI_TCR = amount_of_bytes;
SPI_PTCR = SPI_PTCR_RXTEN | SPI_PTCR_TXTEN;

I have tried adding
SPI_PTCR = SPI_PTCR_RXTDIS | SPI_PTCR_TXTDIS;
in the beginning of the interrupt but that didn't help.

Any ideas what I might be doing wrong?


Top
 Profile  
 
 Post subject: Re: Problem with AT91SAM7S256, SPI and DMA
PostPosted: Fri Oct 09, 2009 1:49 pm 
Offline

Joined: Wed Oct 17, 2007 10:07 am
Posts: 3
Some more information...

I found out that the ENDRX flag gets set as soon as I enable clock for SPI via PMC_PCER. After that, the only way to have it reset seems to be writing SPI_RCR. The problem is that, even though the flag is reset, it will remain reset for one instruction time. I mean, when I step the code instruction by instruction, once I execute SPI_RCR = x, the flag gets reset, but as soon as I execute the next line, it gets set again.

I am getting totally lost with this...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: