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  [ 3 posts ] 
Author Message
 Post subject: Set chipselects for DMA SPI transfer
PostPosted: Wed Jul 25, 2012 1:23 pm 
Offline

Joined: Fri Aug 13, 2010 11:38 am
Posts: 9
Hi all,

I am using 3 different chip selects on my spi bus, all transferred within one DMA cycle. This is the way I set the chip selects for different registers in my SPI Buffers:
Code:
    for(int i=0; i<16;i++){
        fpgaTxBuffer[i] &= 0x0FFFF;
        linkTxBuffer[i] |= 0x10000;
    }
    for(int i=16;i<48;i++){
        fpgaTxBuffer[i] |= 0x30000;
        linkTxBuffer[i] |= 0x10000;
    }


This takes about 35 uS to complete, and together with other interrupt routines, in a 100uS frame it is quite a lot of time.

Is there a way to set my chipselects quicker?

Thanks in advance,
Ruben


Last edited by rdamoise on Thu Jul 26, 2012 11:11 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Set chipselects for DMA SPI transfer
PostPosted: Wed Jul 25, 2012 10:59 pm 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 330
Location: USA
rdamoise wrote:

for(int i=0; i<16;i++){
fpgaTxBuffer[i] &= 0x0FFFF;
linkTxBuffer[i] |= 0x10000;
}
for(int i=16;i<48;i++){
fpgaTxBuffer[i] |= 0x30000;
linkTxBuffer[i] |= 0x10000;
}


If nobody comes up with a faster algorithm/technique, then the least you could do is code the loops more efficiently, i.e. use pointers instead of indexing into arrays.

Code:
        struct foo     fpgaTxBuffer, *p, *z;
        struct bar     linkTxBuffer, *q;

        p = fpgaTxBuffer;
        z = fpgaTxBuffer + 16;
        q = linkTxBuffer;
        do {
                *p++ = *p & 0x0FFFF;
                *q++ = *q | 0x10000;
        } while (p < z);
        z = fpgaTxBuffer + 48;
        do {
                *p++ = *p | 0x30000;
                *q++ = *q | 0x10000;
        } while (p < z);


Regards


Top
 Profile  
 
 Post subject: Re: Set chipselects for DMA SPI transfer
PostPosted: Thu Jul 26, 2012 11:12 am 
Offline

Joined: Fri Aug 13, 2010 11:38 am
Posts: 9
Thanks, already gained 3uS.


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 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: