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

REG: LPC 2129 SPI

Good Morning.

Have tried to communicate with 25LC160 eeprom through LPC2124 USING keil u 4 and proteus
In that case , in transmission section SPI terminal gives 00 when am transmit 00 but in that case of 01 terminal gives ? in the position of 0 th bit .

In keil simulation SOSPDR is not accepting the data which am giving

SCK - 1Mhz

#include <LPC21xx.H>

#define bit(x)  (1<<x)

#define SCK0    8
#define MISO0   10
#define MOSI0   12


void io_config(void);
void spi_config(void);
void spi_tx(unsigned char);
void delay(unsigned int);


int main(void)
{
        io_config();
        spi_config();
        IOSET0 |= 1<<1;
        //spi_tx(0x00);
        //spi_tx(0x00);
        spi_tx(0x01);
        while(1)
        {

//              IOSET0 |= 1<<1;
//              delay(1000);
//              IOCLR0 |= 1<<1;
//              delay(1000);





        }

}

void io_config(void)
{
        IODIR0 |= 1<<1;
}

void spi_config(void)
{
         VPBDIV = 0X02;
         PINSEL0 = 0 | bit(SCK0) | bit(MISO0) | bit(MOSI0);
         S0SPCR  = 0X20;
         S0SPCCR = 0X1E;
}

void delay(unsigned int dly_val)
{
         unsigned int i;
         for(i=0;i<dly_val;i+=1)
         {
           ;
         }

}

void spi_tx(unsigned char data)
{
         unsigned char dummy;
         unsigned char dummy1;
         IOCLR0 |= 1<<1;
         dummy = S0SPDR;
        // delay(2000);
         dummy1 = S0SPSR;
        // delay(2000);

         S0SPDR =data;
        // delay(2000);                         // Intialize transfer
        while(!(S0SPSR&(0x80)));            // Wait for trasfer to finish
        // delay(2000);
        dummy = S0SPDR;
        // delay(2000);

         IOSET0 |= 1<<1;
         delay(2000);


}

Give some idea guys

0