LPC1114 SPI Question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1114 SPI Question

1,713 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by shaguarhan on Fri Aug 12 15:07:19 MST 2011
Hello every one,
I am using LPC1114 to program on a Flash.At beginning of the work i have seen the document about how the SPI works.Then I understood all of them.According to the document(the example of SSP) I have programmed,but there is no CLK signal.My hardware is very easy and correctly,and now I only need to generate a CLK for SPI.

I have found many textes in Internet about how to initiate SPI.But I dont know which one is correct.In the example there are a lot of situations,for example loopbacktest and so on.Who can give me a easy example ?how can I iniate SPI0 and how to write the IO Config.
I think the document is not for LPC1114.......
thanks for your help :)
0 Kudos
Reply
7 Replies

1,599 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Wed Sep 21 00:38:45 MST 2011
Hi shaguarhan,

The sample code of SSP available in LPC1100 examples is definitely for LPC1114 Xpresso board and to run the code you need two LPCXpresso boards one configure as MASTER and other as SLAVE. It is better to run and understand this code on LPCXpresso boards first and get some basic understanding of SPI then use this knowledge in your own application.

Kind Regards,
0 Kudos
Reply

1,599 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Sep 18 04:49:32 MST 2011

Quote: KTownsend
... when you want to read a byte, you just 'send' a dummy byte like 0xFF on MOSI and read whatever is coming in on MISO.



In Master mode :)

In Slave mode your slave is waiting until the master is speaking :eek:
Slaves are not allowed to talk before they are asked :)
0 Kudos
Reply

1,599 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Sun Sep 18 04:35:32 MST 2011
Send and receive are exactly the same with SPI ... there is always a byte (etc.) being transferred in both directions every time ... when you want to read a byte, you just 'send' a dummy byte like 0xFF on MOSI and read whatever is coming in on MISO.

You'll need to change these register names and look up the bits in the appropriate section of the UM, but it's probably a good exercise anyway to understand what these register and bit values mean anyway ... but you can see the principle here.  This functions handles both read and write attempts via SSP/SPI:

/**************************************************************************/
/*!
    This function both reads and writes data. For write operations, include data
    to be written as argument. For read ops, use dummy data as arg. Returned
    data is read byte val.
*/
/**************************************************************************/
uint8_t w25q16bv_TransferByte(uint8_t data)
{
    /* Move on only if NOT busy and TX FIFO not full */
    while ((SSP_SSP0SR & (SSP_SSP0SR_TNF_MASK | SSP_SSP0SR_BSY_MASK)) != SSP_SSP0SR_TNF_NOTFULL);
    SSP_SSP0DR = data;
  
    /* Wait until the busy bit is cleared and receive buffer is not empty */
    while ((SSP_SSP0SR & (SSP_SSP0SR_BSY_MASK | SSP_SSP0SR_RNE_MASK)) != SSP_SSP0SR_RNE_NOTEMPTY);
    // Read the queue
    return SSP_SSP0DR;
}
0 Kudos
Reply

1,599 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dirtyBits on Sun Sep 18 01:07:46 MST 2011

Quote: Zero
Are you aware that SPI means shifting bits from MOSI to SPI slave and back to MISO ? So there's no clock if SPI isn't shifting (=reading or writing) :eek:

This simple semihosting  sample is just writing a byte. If you connect MOSI and MISO, it's reading back this value :)

[ATTACH]531[/ATTACH]



[SIZE=3]zero how about code for receiving a byte of data?
Just nee a simple very basic example code for SSP![/SIZE]
0 Kudos
Reply

1,599 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Fri Aug 19 15:29:43 MST 2011
Hi,

Please refer to the sample code posted online....it has SSP example.
Thanks.

http://ics.nxp.com/support/documents/microcontrollers/zip/code.bundle.lpc11xx.keil.zip
0 Kudos
Reply

1,599 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by quocthang on Sat Aug 13 08:01:48 MST 2011
please help me about spi
i don't known
0 Kudos
Reply

1,599 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Aug 13 07:24:52 MST 2011

Quote: shaguarhan
I have programmed,but there is no CLK signal. :confused:



Are you aware that SPI means shifting bits from MOSI to SPI slave and back to MISO ? So there's no clock if SPI isn't shifting (=reading or writing) :eek:

This simple semihosting  sample is just writing a byte. If you connect MOSI and MISO, it's reading back this value :)

[ATTACH]531[/ATTACH]
0 Kudos
Reply