<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>LPC2378 interface with AT45DB321D(SPI)</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/39980/lpc2378-interface-with-at45db321d-spi</link><description> 
 
Dear Sir, I am trying to make communication with flash memory
AT45DB321D with LPC 2378 every register get modified except data
register, 
here is the code given below, 

 

#define Cclk 12000000 //Processor clock
#define Pclk Cclk //Periferals clock</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: LPC2378 interface with AT45DB321D(SPI)</title><link>https://community.arm.com/thread/67910?ContentTypeID=1</link><pubDate>Sat, 01 Dec 2012 07:04:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:657d8000-3029-4eb1-ad5c-f8d32b577655</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Have you really spent some debug time, actually comparing what you
have written in your source code with the information in the
datasheet? Not assumed that what you wrote in the code is correct but
actually used pen and paper and scribbled down the bit values as
suggested from the processor user manual and then compared with the
text you have in the code?&lt;/p&gt;

&lt;p&gt;
Another thing - have you noticed that the processor have both SPI
and SSP0? And that SSP0 (synchronous serial port) can be configured
as SPI? Have you noticed the differences (advantages) of using the
SSP0 instead of SPI device? You want to program a flash - isn&amp;#39;t it an
advantage to select the hardware peripherial that supports FIFO,
allowing you to perform multiple byte writes without code
intervention?&lt;/p&gt;

&lt;p&gt;
Anyway:&lt;/p&gt;

&lt;pre&gt;
        PINSEL0 |= 0xC0000000;                  //P0.15    spi pin configuration
        PINSEL1 |= 0x0000003C;                  //P0.17,P0.18,P0.16

&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
What does the comment &amp;quot;spi pin configuration&amp;quot; mean?&lt;br /&gt;
It would have helped more if you had written &amp;quot;P0.15 set as SCL&amp;quot;?&lt;/p&gt;

&lt;p&gt;
What does the comment &amp;quot;P0.17,P0.18,P.16&amp;quot; mean? Wouldn&amp;#39;t it have
helped more if you told what mapping you configured, so P0.16=SSEL,
P0.17=MISO, P0.18=MOSI? Or maybe you don&amp;#39;t want your comments to
actually help the reader understand what magic a source line
does?&lt;/p&gt;

&lt;p&gt;
And are you sure you should select P0.16 as SSEL? Aren&amp;#39;t you
supposted to be SPI master? Did you read the processor
manual?&lt;/p&gt;

&lt;pre&gt;
If the SSEL signal goes active, when the SPI block is a master, this indicates another
master has selected the device to be a slave. This condition is known as a mode fault.
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
And further down:&lt;/p&gt;

&lt;pre&gt;
If the Px.y/SSEL/... pin is assigned the SSEL function in Pin Function Select Register 0,
the SSEL signal must always be inactive when the SPI controller is a master.
&lt;/pre&gt;

&lt;p&gt;
So how did you plan to use SSEL? Didn&amp;#39;t you intend to inform the
flash memory chip when to listen to the SPI communication? How? I
don&amp;#39;t see any single source line that seems to want to syncrhonize
any transfers by giving that flash memory any slave-select, allowing
the slave to know what clock pulse that would correspond to the first
bit of the transfer.&lt;/p&gt;

&lt;pre&gt;
S0SPCCR =0x2c ;         //0x2C
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
So what help is it with a comment &amp;quot;0x2C&amp;quot; to a source line that
assigns the value 0x2c? Can you give us some hints what help the
comment brings?&lt;/p&gt;

&lt;p&gt;
Where can we see any information what PCLK you have configured?
And what master clock frequency you computed and assigned to the SPI
Clock Counter Register?&lt;/p&gt;

&lt;pre&gt;
       S0SPCR = 0xb8;          //0xb8
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
Who will be able to figure out, from your comment, that this line is
expected to:&lt;br /&gt;
- 0x80=0x80: Request an interrupt each time SPIF or MODF are
activated? By the way - you don&amp;#39;t seem to have any interrupt handler,
so why did you want to set this bit?&lt;br /&gt;
- 0x40=0x00: Want to send data with least significant bit first?&lt;br /&gt;
- 0x20=0x20: Wants the SPI to operate as master?- Want SCK to be
active high?&lt;br /&gt;
- 0x10=0x10: Want to have the clock polarity so it is active low?&lt;br /&gt;
- 0x08=0x08: Want to have the clock phase so data is sampled on
second clock edge?&lt;br /&gt;
- 0x04=0x00: Want to send and receive 8 bits/transfer?&lt;br /&gt;
- 0x03=0x00: Leave reserved bits zero?&lt;/p&gt;

&lt;p&gt;
I just can&amp;#39;t see how that comment 0xb8 is really helping a reader.
It would probably not help you either.&lt;/p&gt;

&lt;p&gt;
You write:&lt;br /&gt;
&amp;quot;Every register gets modified except data register&amp;quot;.&lt;/p&gt;

&lt;p&gt;
But have you figured out what to expect from this data register?
It is not a memory cell. So values written into it can&amp;#39;t be read
back. You have to perform a full 8-bit transfer before it is
meaningful to read anything from it. The manual says that incomming
data goes through a shift register and will be latched and presented
to this data register after a full transfer is done. And have you
made any attempts to verify with an oscilloscope that the MOSI pin do
shift out the value you write to this register? That the SCL pin
counts pulses while MOSI sends out the data? That the SSEL pin
informs the external memory chip that a SPI transfer is active?&lt;/p&gt;

&lt;pre&gt;
while (!(S0SPSR &amp;amp; SPIF));
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
Doesn&amp;#39;t this bit get set? If it does, then it indicates that the SPI
master have managed to perform a full word transfer and that you
either can send next word, or read back any received word from the
other side. But it obviously does not indicate that the SPI slave on
the other side have understood that you made an SPI transfer. That
requires you to give a proper slave select - and that all signals are
correctly connected to that flash memory chip.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>