Content originally posted in LPCWare by Scribe on Tue Jun 18 05:27:29 MST 2013Hi 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 <LPC43xx.h></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->SFSP3_6 = 1; // MISO</div><div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SCU->SFSP3_7 = 1; // MOSI</div><div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SCU->SFSP3_3 = 1; // SCK</div><div><span class="Apple-tab-span" style="white-space: pre;"> </span>LPC_SCU->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->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->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->DR = 0xA1;</div><div><span class="Apple-tab-span" style="white-space: pre;"> </span>while( !(LPC_SPI->SR & 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>