EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

SPI Setup on AT91SAM7S256

Started by Mark Borgerson July 7, 2006
Hi,

I've spent the last few hours trying to set up the SPI port
on the SAM7S256 to send single bytes on command.  My scope shows
me no SCK pulses or data pulses.   I suspect that I have
messed up something in the setup of the clocks, peripheral pins,
or SPI registers.  At this point, I'm not too concerned with
polarity, delays, or SPI baud Rate.  I just want to see pulses
on SCK!!!!!

I haven't been able to find a simple example of SPI port setup
and usage after a few hours of searching on the net.

Can anyone provide source code (or a link to an example) that
shows the proper sequence of steps for setting up the AT91SAM7S256
SPI port clocks, pins, and registers so I can send a byte
by storing it in the SPI TDR and waiting for TXEmpty?

Mark Borgerson

Mark Borgerson wrote:
> Hi, > > I've spent the last few hours trying to set up the SPI port > on the SAM7S256 to send single bytes on command. My scope shows > me no SCK pulses or data pulses. I suspect that I have > messed up something in the setup of the clocks, peripheral pins, > or SPI registers. At this point, I'm not too concerned with > polarity, delays, or SPI baud Rate. I just want to see pulses > on SCK!!!!!
I am unfamiliar with the SAM7S256, but you *must* be the SPI master to be the source SCK (clock). Have you configured the SAM7S256 as the SPI master? -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." The Eagles, "Already Gone" The Beatles were wrong: 1 & 1 & 1 is 1
In article <gOrrg.17279$Ud4.15765@bignews1.bellsouth.net>, 
mike@mnmoran.org says...
> Mark Borgerson wrote: > > Hi, > > > > I've spent the last few hours trying to set up the SPI port > > on the SAM7S256 to send single bytes on command. My scope shows > > me no SCK pulses or data pulses. I suspect that I have > > messed up something in the setup of the clocks, peripheral pins, > > or SPI registers. At this point, I'm not too concerned with > > polarity, delays, or SPI baud Rate. I just want to see pulses > > on SCK!!!!! > > I am unfamiliar with the SAM7S256, but you *must* be the > SPI master to be the source SCK (clock). Have you configured > the SAM7S256 as the SPI master? >
I think so---but I'll check to make sure. Thanks. Mark Borgerson
In article <MPG.1f181521f127141e98a259@newsgroups.comcast.net>, Mark 
Borgerson <mborgerson.at.comcast.net> says...
> In article <gOrrg.17279$Ud4.15765@bignews1.bellsouth.net>, > mike@mnmoran.org says... > > Mark Borgerson wrote: > > > Hi, > > > > > > I've spent the last few hours trying to set up the SPI port > > > on the SAM7S256 to send single bytes on command. My scope shows > > > me no SCK pulses or data pulses. I suspect that I have > > > messed up something in the setup of the clocks, peripheral pins, > > > or SPI registers. At this point, I'm not too concerned with > > > polarity, delays, or SPI baud Rate. I just want to see pulses > > > on SCK!!!!! > > > > I am unfamiliar with the SAM7S256, but you *must* be the > > SPI master to be the source SCK (clock). Have you configured > > the SAM7S256 as the SPI master? > > > I think so---but I'll check to make sure. >
The question of setting the Master bit prompted me to examine the SPI Mode Register. I was, indeed, in the master mode. However, I also looked at the Status Register---where I found that the SPIENS bit was cleared---indicating that the SPI was disabled! I then found an errant setting of the SWRST (Software SPI Reset) had found its way into the code AFTER all the setup instructions. DOH! The first hurdle in the SPI steeplechase has been cleared---after a bit of a stumble. Now it's onward to figuring out the difference between fixed and variable chip selects, delays, using the PDC for block transfers, etc., etc. The eventual goal is to port Lewin Edward's DOSFS to my board to use an SD card as data storage. Mark Borgerson
Mark Borgerson schrieb:
> In article <MPG.1f181521f127141e98a259@newsgroups.comcast.net>, Mark > Borgerson <mborgerson.at.comcast.net> says... >> In article <gOrrg.17279$Ud4.15765@bignews1.bellsouth.net>, >> mike@mnmoran.org says... >>> Mark Borgerson wrote: >>>> Hi, >>>> >>>> I've spent the last few hours trying to set up the SPI port >>>> on the SAM7S256 to send single bytes on command. My scope shows >>>> me no SCK pulses or data pulses. I suspect that I have >>>> messed up something in the setup of the clocks, peripheral pins, >>>> or SPI registers. At this point, I'm not too concerned with >>>> polarity, delays, or SPI baud Rate. I just want to see pulses >>>> on SCK!!!!! >>> I am unfamiliar with the SAM7S256, but you *must* be the >>> SPI master to be the source SCK (clock). Have you configured >>> the SAM7S256 as the SPI master? >>> >> I think so---but I'll check to make sure. >> > The question of setting the Master bit prompted me to examine > the SPI Mode Register. I was, indeed, in the master mode. > However, I also looked at the Status Register---where I found > that the SPIENS bit was cleared---indicating that the SPI > was disabled! I then found an errant setting of the SWRST > (Software SPI Reset) had found its way into the code AFTER all > the setup instructions. DOH! > > > The first hurdle in the SPI steeplechase has been cleared---after > a bit of a stumble. Now it's onward to figuring out the difference > between fixed and variable chip selects, delays, using the > PDC for block transfers, etc., etc. The eventual goal is to > port Lewin Edward's DOSFS to my board to use an SD card as > data storage.
You could also use this SD+FAT32 implementation: http://www.mikrocontroller.net/articles/ARM_MP3/AAC_Player
In article <44afd9c2$0$26260$9b4e6d93@newsread2.arcor-online.net>, 
usenet@andreas-s.net says...
> Mark Borgerson schrieb: > > In article <MPG.1f181521f127141e98a259@newsgroups.comcast.net>, Mark > > Borgerson <mborgerson.at.comcast.net> says... > >> In article <gOrrg.17279$Ud4.15765@bignews1.bellsouth.net>, > >> mike@mnmoran.org says... > >>> Mark Borgerson wrote: > >>>> Hi, > >>>> > >>>> I've spent the last few hours trying to set up the SPI port > >>>> on the SAM7S256 to send single bytes on command. My scope shows > >>>> me no SCK pulses or data pulses. I suspect that I have > >>>> messed up something in the setup of the clocks, peripheral pins, > >>>> or SPI registers. At this point, I'm not too concerned with > >>>> polarity, delays, or SPI baud Rate. I just want to see pulses > >>>> on SCK!!!!! > >>> I am unfamiliar with the SAM7S256, but you *must* be the > >>> SPI master to be the source SCK (clock). Have you configured > >>> the SAM7S256 as the SPI master? > >>> > >> I think so---but I'll check to make sure. > >> > > The question of setting the Master bit prompted me to examine > > the SPI Mode Register. I was, indeed, in the master mode. > > However, I also looked at the Status Register---where I found > > that the SPIENS bit was cleared---indicating that the SPI > > was disabled! I then found an errant setting of the SWRST > > (Software SPI Reset) had found its way into the code AFTER all > > the setup instructions. DOH! > > > > > > The first hurdle in the SPI steeplechase has been cleared---after > > a bit of a stumble. Now it's onward to figuring out the difference > > between fixed and variable chip selects, delays, using the > > PDC for block transfers, etc., etc. The eventual goal is to > > port Lewin Edward's DOSFS to my board to use an SD card as > > data storage. > > You could also use this SD+FAT32 implementation: > http://www.mikrocontroller.net/articles/ARM_MP3/AAC_Player >
That certainly looks interesting. I will look through the source code and see whether it will suit my application. Thanks. Mark Borgerson

The 2024 Embedded Online Conference