EmbeddedRelated.com
Forums

LPC2368 SPI Driver

Started by "Var...@mstglobal.com [lpc2000]" December 22, 2014
Hi All,
In my setup I have my LPC connected to Ubicom IP3023. The Ubicom is
master and LPC is slave. Currently we are using Bit banging as a means
to communicate between these devices. This is rather slow and we plan to
use the hardware. I am very new to this so can anyone suggest a sample
code to look at for SPI in slave mode on LPC? Also if there are any
samples for master mode will also be useful.
Regards,
Varun

Posted by: Varun Chandramohan



An Engineer's Guide to the LPC2100 Series

Hi,

Did you check if the IP3K do really support SPI hardware ?
If not then SPI hardware support (for speed purposes) will
be likely not very useful.

Br,

Armand
> Hi All,
> In my setup I have my LPC connected to Ubicom IP3023. The Ubicom is
> master and LPC is slave. Currently we are using Bit banging as a means
> to communicate between these devices. This is rather slow and we plan to
> use the hardware. I am very new to this so can anyone suggest a sample
> code to look at for SPI in slave mode on LPC? Also if there are any
> samples for master mode will also be useful.
> Regards,
> Varun
>


Posted by: a...@mini-amd.org



In the case where the LPC2368 is an OUTPUT device (it only receives information), the solution is trivial. Set up the SPI gadget to receive a byte and create an interrupt. Once the interrupt is received, grab the byte and store it in a queue. Pretty simple! In fact, this is exactly the way I handle SPI between an FPGA and an LPC1768.

Where the LPC2368 is going to provide data, there is going to need to be some kind of protocol involved above the SPI layer. SPI would like to get a received byte of data (or something) for every byte it sends. This requires that the SPI gadget on the LPC1768 have the data in the output buffer BEFORE the gadget is even selected. Or, something in the agreed protocol indicates when the data is actually ready.

If you already have this protocol all worked out, it's pretty easy to configure the LPC2368. Unfortunately, my code is for the LPC1768 and the interrupt controllers are different (I believe).

I posted a file to the Files section named SPI_Slave.c. I don't know if it will be useful due to the differences in hardware but maybe it will give you a hint.

Richard
On 22/12/14 22:28, l... wrote:
Hi,

Did you check if the IP3K do really support SPI hardware ?
If not then SPI hardware support (for speed purposes) will
be likely not very useful.

Br,

Armand

I based it on the fact that IP2k had hardware support however for some reason the driver was changed to bit banging in IP3k. I dont know where I can find the information regarding the change in IP3K. Do you have any idea? I dont seem to find anything relevant in the datasheets or I am missing something.

Regards,
Varun

> Hi All,
> In my setup I have my LPC connected to Ubicom IP3023. The Ubicom is
> master and LPC is slave. Currently we are using Bit banging as a means
> to communicate between these devices. This is rather slow and we plan to
> use the hardware. I am very new to this so can anyone suggest a sample
> code to look at for SPI in slave mode on LPC? Also if there are any
> samples for master mode will also be useful.
> Regards,
> Varun
>
LPC is going to provide data. I already have a higher level protocol as you described below. I even managed to configure the device and could get it work. The problem is on the other side IP3K (Ubicom), this works in bit banging mode which really eats up cpu. Thanks for the example code, it is useful for my understanding. I know this LPC forums but I am hopelessly stuck on Ubicom because of their lack of resources :-(

On 23/12/14 07:18, l... wrote:

In the case where the LPC2368 is an OUTPUT device (it only receives information), the solution is trivial. Set up the SPI gadget to receive a byte and create an interrupt. Once the interrupt is received, grab the byte and store it in a queue. Pretty simple! In fact, this is exactly the way I handle SPI between an FPGA and an LPC1768.

Where the LPC2368 is going to provide data, there is going to need to be some kind of protocol involved above the SPI layer. SPI would like to get a received byte of data (or something) for every byte it sends. This requires that the SPI gadget on the LPC1768 have the data in the output buffer BEFORE the gadget is even selected. Or, something in the agreed protocol indicates when the data is actually ready.

If you already have this protocol all worked out, it's pretty easy to configure the LPC2368. Unfortunately, my code is for the LPC1768 and the interrupt controllers are different (I believe).

I posted a file to the Files section named SPI_Slave.c. I don't know if it will be useful due to the differences in hardware but maybe it will give you a hint.

Richard
Hi,

Although completely off topic :
The IP3K has no decent SPI support at all. Based on the scarce info
I had, you need to use the interrupt based approach (which is already a
big puzzle itself) or use a hardware thread.

Why do you use (a 5 year obsoleted) device anyway (and besides Ubicom
does not exist for more than 3 years) ?
IMHO you could use one of the LPC43xx series which has better options or
if you want to use a gigabit ethernet interface then there are even
better options.

Br,

Armand
> On 22/12/14 22:28, l...
> wrote:
> Hi,
>
> Did you check if the IP3K do really support SPI hardware ?
> If not then SPI hardware support (for speed purposes) will
> be likely not very useful.
>
> Br,
>
> Armand
>
> I based it on the fact that IP2k had hardware support however for some
> reason the driver was changed to bit banging in IP3k. I dont know where I
> can find the information regarding the change in IP3K. Do you have any
> idea? I dont seem to find anything relevant in the datasheets or I am
> missing something.
>
> Regards,
> Varun
>
>> Hi All,
>> In my setup I have my LPC connected to Ubicom IP3023. The Ubicom is
>> master and LPC is slave. Currently we are using Bit banging as a means
>> to communicate between these devices. This is rather slow and we plan to
>> use the hardware. I am very new to this so can anyone suggest a sample
>> code to look at for SPI in slave mode on LPC? Also if there are any
>> samples for master mode will also be useful.
>> Regards,
>> Varun
>


Posted by: a...@mini-amd.org