I am trying to get the SSP to communicate with the LCD. I am using gcc (4.1.1). I found some SSP code found in http://www.standardics.nxp.com/support/ … vision.zip. I have modified the pin mapping of the code to work with the LPC-2378-STK.
When I monitor the MISO0 pin (1.23), I get a constant 2.4 volts on an oscilloscope while sending (or not sending) data using the code below.
void InitLCD(void)
{
int i, Dummy;
FIO1DIR |= BIT26; //Set backlight pin to output
Backlight(1); //Turn on backlight
/* enable clock to SSP0 for security reason. By default, it's enabled already */
PCONP |= (1 << 21);
/* Output port 1.20 SSP0 SCK0, port1.21 SSP0 SSEL0, port1.23 SSP0 MISO0*/
PINSEL3 |= 3 << 8 | 3 << 10 | 3 << 14;
/* Set DSS data to 9-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 15 */
SSP0CR0 = 8 | 7 << 8;
/* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
SSP0CPSR = 0x2;
for ( i = 0; i < FIFOSIZE; i++ )
{
Dummy = SSP0DR; /* clear the RxFIFO */
}
//if ( install_irq( SPI0_INT, (void *)SSP0Handler, HIGHEST_PRIORITY ) == FALSE )
//{
//return (FALSE);
//}
/* Device select as master, SSP Enabled */
SSP0CR1 = 1 << 1;
/* Set SSPINMS registers to enable interrupts */
/* enable all error related interrupts */
//SSP0IMSC = SSPIMSC_RORIM | SSPIMSC_RTIM;
}
void WriteSpiData(unsigned int data)
{
char Dummy;
while ( !(SSP0SR & SSPSR_TNF) );
SSP0DR = (data | 0x0100);
/* Wait until the Busy bit is cleared */
while ( !(SSP0SR & SSPSR_BSY) );
}
http://www.standardics.nxp.com/support/ … pc2378.pdf
PCONP is on page 55. PINSEL3 is on page 126. SSP registers (SSP0CR0, SSP0CPSR, SSP0CR1, SSP0SR and SSP0DR) is on page 389-391.
I have performed a sanity check by setting the direction of pin 1.23 to output and toggling the pin on and off. It shows up as a full 3.3 volts change.
What could I be doing wrong? (It seems like I am not setting up the peripheral output correctly but I have checked the code. )