lpcware

SPI troubles

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Scribe on Tue Jun 18 05:27:29 MST 2013

Hi guys,


I've written some simple SPI code using Keil, however I'm unable to get the module to transmit and trigger the SPI tranfer complete interrupt flag. Am I missing anything from the following code?


<div>#define  CMSIS_BITPOSITIONS 1</div>
<div>#include &lt;LPC43xx.h&gt;</div>
<div>int main( void )</div>
<div>{</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>// Update the System Core Clock</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>SystemCoreClockUpdate();</div>
<div> </div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>// Configure pins for SPI</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SCU-&gt;SFSP3_6 = 1; // MISO</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SCU-&gt;SFSP3_7 = 1; // MOSI</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SCU-&gt;SFSP3_3 = 1; // SCK</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SCU-&gt;SFSP3_8 = 1; // SSEL</div>
<div> </div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>// Configure the SPI Master Clock (PCLK_SPI / SPCCR)</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SPI-&gt;CCR = 16;</div>
<div> </div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>// Configure the SPI Module for Master Mode and X</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SPI-&gt;CR |= SPI_CR_MSTR_Msk | SPI_CR_SPIE_Msk;</div>
<div> </div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>while( 1 )</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SPI-&gt;DR = 0xA1;</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>while( !(LPC_SPI-&gt;SR &amp; SPI_SR_SPIF_Msk) );</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div>}</div>
<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif;">Many thanks</span></div>

Outcomes