SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By hibchibbler
#107412
Hi,

Please help me understand
what my options are with hooking up an SPI device.

the lpc2378 has an SPI Block
and an SSP block.

Is it true that the SPI block is unusable because the MOSI pin is used as a button2 input?
If so, then I have to utilize the SSP block.

But it appears that SSP0 goes to the LCD.
Which leaves me SSP1

So, is it correct to say my only option for hooking up an SPI device is to use SSP1?
And if so, I don't get the benefit of the interrupt for status and mode fault that comes with the SPI block?


Please help clear me up.

Schematic:
http://www.olimex.com/dev/pdf/ARM/LPC/L ... vC-sch.pdf

lpc2378 user manual:
http://www.keil.com/dd/docs/datashts/ph ... 3xx_um.pdf


Thanks very much,
Daniel Ferguson
By mjbcswitzerland
#108466
Hi Daniel

Although some SSP / SPI interfaces are connected on the bard that you are using, each of the peripherals is controlled by a chip-select line.
When you add further SPI devices they will also have their own CS lines, meaning that one SSP / SPI bus can be shared by multiple peripherals.
The advantage of the multiple SSP / SPI in the LPC2378 is that this gives a further method of isolating each bus, making things simpler if the peripherals need different settings (clock polarity, maximum speed, etc.) or if one peripheral is using up a large bandwidth on one bus.

Regards

Mark

www.uTasker.com
By dev1211
#138593
Hello...This is very urgent..I am new to arm processors and embedded systems. I have purchased an lpc2378-stk kit. i have tried doing everything possible to run the lcd. The lcd has GE 8 sticker. pls write a simple c program for me displaying some text like abcd...i want to know the details of ssp control registers especially the ssp0cro and ssp0cr1 values. also i have understood that if we write any values to data register, it will automatically transmit serially. also that values has to be hexa equivalent of ascii values of characters. all my questions can be answered by writing a small program for me pls. i request your help pls. thanks.

My code is as follows:


#include <LPC23xx.H>
int main()
{
SCS = 0X00000001;

SSP0CR0 = 0X2F08;
SSP0CR1 = 0X02;
SSP0CPSR = 0X78;

PINSEL7 = 0x00000000; // Select P3.25 as GPIO for LCD_RST lpc2378
PINMODE3 = 0X00000000;

FIO3DIR = 0X02000000; // Select P3.25 - LCD_RST LPC2378 as OUTPUT


PINSEL0 = 0x80000000; //Select P0.15 as SCK0 in LPC2378
PINMODE0 = 0X00000000;//Select P0.0 to P0.15 as Pull Up Resistor Mode

PINSEL1 = 0x00000022; //Select P0.16 as SSEL0 and P0.17 as MISO0 lpc2378
PINMODE1 = 0X00000000;//Select P0.16 to P0.31 as Pull Up Resistor Mode


PINSEL3 = 0x00000000; //LCD Backlight (P1.26 as GPIO for anabling LCD Backlight)...
PINMODE3 = 0X00000000;
FIO1DIR = 0X04000000;
FIO1SET = 0x04000000; //...LCD Backlight



SSP0DR = 0X2CA;// Display Control
SSP0DR = 0X600;
SSP0DR = 0X61F;
SSP0DR = 0X68A;

SSP0DR = 0X2BB;// Common Scan Direction
SSP0DR = 0X600;

SSP0DR = 0X2D1;// Internal Oscillator ON
//SSP0DR = 0X2D2;// Internal Oscillator OFF

SSP0DR = 0X294;// Sleep out

SSP0DR = 0X220;// Power Control
SSP0DR = 0X60F;

SSP0DR = 0X2A6; // Normal Display

SSP0DR = 0X2BC;// Data Scan Direction
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X601;

SSP0DR = 0X281;// Electronic Volume Control
SSP0DR = 0X624;
SSP0DR = 0X603;

SSP0DR = 0X225;//No Operation

SSP0DR = 0X275;// PASET
SSP0DR = 0X600;
SSP0DR = 0X600;

SSP0DR = 0X215;// CASET
SSP0DR = 0X600;
SSP0DR = 0X600;

SSP0DR = 0X2CE;// 256-Color Position Set
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;
SSP0DR = 0X600;

SSP0DR = 0X2AF;// Display ON

SSP0DR = 0X25C;// Ram Write
while (1)
{

SSP0DR = 0X645;
SSP0DR = 0X642;
SSP0DR = 0X643;
SSP0DR = 0X644;
}

}
By mjbcswitzerland
#138610
Hi

There are many examples for doing this - search the NXP libraries and check for demo code for the board that you have.

The main problem with the code that you have shown is that it doesn't wait for data to be sent. It will be overwriting data in the tx buffer before it has had the chance to be transmitted and so will probably only send one or two bytes of corrupted data during the initialisation. After each write to the SSP data register you can wait for that byte to be transmitted by polling the TFE flag in the status register:
eg.
SSP0DR = 0x00;
while ((SSP0SR & SSP_TFE) == 0) {} // wait for the dat ato be transmitted

Furthermore, the display usually requires some initialisation delays when powering up and configuring (eg. between negating the reset and starting writing command,s and after enabling the internal oscillator).

The SSP should be set to 9-bit mode, where the bit 0x100 in the transmitted data defines whether a command or data is being sent - I am not sure that values in the data register larger than 0x1ff are permitted (?).

It is useful to use an oscilloscope (or logic analyser) when starting with this to verify that all signals are as expected.

Regards

Mark

http://www.uTasker.com