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

LPC17xx SPI simulation

Hello everyone i am new to microcontroller programming.
I am doing a project using LPC1768. To learn about spi i used a debug feature of debugger. I wrote the follwing program for spi simulation.

#include <LPC17xx.H>
int main(void)
{
        SystemInit();
        LPC_SC->PCONP       |= 0x00000100;
        //LPC_SC->PCLKSEL0    |= 0x00200000;
        LPC_GPIO0->FIODIR    |= 0x00010000;
        LPC_GPIO0->FIOSET    |= 0x00010000;

        LPC_PINCON->PINSEL0  &= 0xC0000000;
        LPC_PINCON->PINSEL1  &= 0xC000003F;

        LPC_SPI->SPCR                = 0x38;
        LPC_SPI->SPCCR               = 0x08;
        while(1)
        {
                  LPC_SPI->SPDR = 0x01;
                  while(!(LPC_SPI->SPSR & 0x80));
        }
}

in simulation after LPC_SPI->SPDR = 0x01;
i am expecting content of SPDR register to be 01.But in simulation SPI dialog box it is showing 00. SPIF bit set to be 1. In the logic analyzer SPI_OUT is always 0.

Thanks in advance.

Regards

0