Atmel website | ARM Community | AVR freaks | Technical Support
Banner
Welcome to AT91SAM Community Forum
http://www.at91.com/samphpbb/

spi chipselect configuration - by user?
http://www.at91.com/samphpbb/viewtopic.php?f=15&t=18585
Page 1 of 1

Author:  NNewUser [ Thu Sep 10, 2009 10:38 am ]
Post subject:  spi chipselect configuration - by user?

Hi,

I have a question:
Is there any way to use user-defined chipselect for the SPI?
Meaning, use another line as a chipselect instead of the peripheral chipselect?

I saw that I can configure the PCS field of the SPI_MR (Mode Register) to 0xF (the forbidden value). If I do so, can I use a user-defined GPIO as a chipselect line?

thanks.

P.S.
I use ATMEL AT91sam7x256

Author:  gerhardf [ Thu Sep 10, 2009 1:26 pm ]
Post subject:  Re: spi chipselect configuration - by user?

hello,
you can use any gpio port as long as your software cares about the state of the port.
as soon as your software would like to use the pdc you have to use the dedicated cs ports.

regards
gerhard

Author:  NNewUser [ Thu Sep 10, 2009 1:44 pm ]
Post subject:  Re: spi chipselect configuration - by user?

Hello,

My software is using the PDC and do cares of the GPIO's state.
But how do I configure the periph to use a user-defined chipselect?
Should I write in the PCS field of SPI_MR the value 0xF?
Could you please post here an example code? It will be very helpful.

Thanks again.

Author:  gerhardf [ Fri Sep 11, 2009 7:05 am ]
Post subject:  Re: spi chipselect configuration - by user?

NNewUser wrote:
My software is using the PDC and do cares of the GPIO's state.

this will work as long as you don't change the slave.

NNewUser wrote:
But how do I configure the periph to use a user-defined chipselect?
Should I write in the PCS field of SPI_MR the value 0xF?

don't care about the PCSD field.

regards
gerhard

Author:  lusher00 [ Tue Feb 16, 2010 7:32 pm ]
Post subject:  Re: spi chipselect configuration - by user?

Hello,

I to am using the AT91SAM7S256 in my design and am trying to do the same thing. The solution doesn't seem quite clear from the previous posts.

gerhardf:

What do you mean when you say "as soon as your software would like to use the pdc you have to use the dedicated cs ports?" The dedicated cs ports are already being used for something else, does this mean I will never be able to use the pdc?

I am unsure whether to use fixed peripheral or variable. I would like the functionality of variable in that I can determine the SPI port configuration by simply setting bits 16-19 in the TX register when I am transmitting but when I set it up that way (the dedicated pins are not programmed to operate with the SPI but as GPIO instead) i can not transfer.

Should I be in fixed or variable mode? Can I program NPCS0-NPCS3 to be GPIO and leave it that way?

Author:  gerhardf [ Tue Feb 16, 2010 10:28 pm ]
Post subject:  Re: spi chipselect configuration - by user?

hello lusher,
if you use the pdc you have to use the dedicated NPCS0-NPCS3 port.
so you have to initialize the port multiplexer in the right way.

regards
gerhard

Author:  lusher00 [ Wed Feb 17, 2010 12:23 pm ]
Post subject:  Re: spi chipselect configuration - by user?

Anyone care to take a crack at the other questions? I am still unsure as to how to set up the port. I am past needing example code but id still like to know how to set the configuration registers so that I don't mess with NPCS0-NPCS3 because I will be using them for other functions.

Author:  gerhardf [ Wed Feb 17, 2010 9:36 pm ]
Post subject:  Re: spi chipselect configuration - by user?

hello lusher,
enclosed you can find an older example of an spi interface with pdc.

regards
gerhard

Attachments:
AT91SAM7S64-SPI-PDC-VARIABLE-IAR430A-1_3.zip [290.58 KiB]
Downloaded 90 times

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/