Data (in S0SPDR register) not being transmitted on MOSI pin of SPI in LPC2148

0

I have written code for transmitting data via SPI of ARM LPC2148. I verified the data in the S0SPDR register using keil debugger and Keil Logic Analyser, but it shows 0x00 always. Even I copied the S0SPDR register in U0THR (UART Transmit Holding Register) but the value in U0THR also remains 0x00 and no data is seen on the serial terminal. Following is my code

#include<lpc214x.h>

void spi_master(void)
{
    char flush1,flush2;
    IOCLR0=(1<<7);           //SSEL=0
    S0SPDR='G';             //Load SPI data register
    while((S0SPSR & 0x80) == 0);  // Wait for flag

    flush1=S0SPDR;  //Read the Data register (as per mentioned in User Manual)
    flush2=S0SPSR;  //Read the Status regisster (w.r.t. user manual) 
    while(!(U0LSR&0X20)); //Wait for the transmit complete flag
    U0THR=flush1;       //Copy data in UOTHR
    IOSET0=(1<<7);     //SET SSEL
}

void main (void)
{
    char c;
    PINSEL0=0X00001500;    //Configure MISO, MOSI and clock pins
    IODIR0=0x000000D0; //Configure IODIR register
    S0SPCCR=0x10;  //Clock counter register
    S0SPCR=0X0020;   //Control register for master mode
    U0LCR=0X83;
    U0DLL=0X61;
    U0DLM=0X00;
    U0LCR=0X03;
    while(1)
    {
        spi_master();
    }
}
arm
spi
asked on Stack Overflow Sep 3, 2019 by madhavi chhugani • edited Sep 3, 2019 by tituszban

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0