This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to interface spi whith lpc2378

thank you
i write thiis code for simple write and read data in spi but i m not getting output

InitSPI();

IOCLR0 = SPI0_SEL; Write_SPI(0x84); // opcode Write on buffer 1 Write_SPI(0x00); Write_SPI(0x55); // data into buffer 1

// data = Read_SPI();

Write_SPI(0x83); //opcode buff to MM Write_SPI(0x00); // location of MM Write_SPI(0x00); // location of MM Delay(1000);

Write_SPI(0x54); // Read opcode for buffer 1 Write_SPI(0x00); // bufffer address

Delay(1000); data = Read_SPI(); TransmitChar0(data>>8); TransmitChar0(data);

}
/***************************************** /* main end */
void InitSPI(void)
{ PCONP |= (1 << 8); PINSEL0 |= 0xC0000000; //P0.15 PINSEL1 |= 0x0000003C; //P0.16,P0.17,P0.18 PCONP |= (1 << 8); S0SPCR = 0x00; IODIR0 = SPI0_SEL; IOSET0 = SPI0_SEL; S0SPCR = 0x20; S0SPCCR = 0x96; // i given 200 khz aproximately // Check it first
}

void Write_SPI(unsigned char spiTx)
{ S0SPDR = spiTx; while(!(S0SPSR & SPIF));
} unsigned char Read_SPI()
{ unsigned char spiRx; spiRx = S0SPDR; return (spiRx);
} void SPI_ISR (void) __irq
{ S0SPINT = 0x01;

VICVectAddr = 0x00000000;
}

0