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

Re:LPC17xx spi simulation

Thanks for your reply.
i found the problem. As u rightly pointed out the problem was with the settings.
i have some questions
first is that SPDR register value never changes why is that?
second what is spi_out? is this signal same as MOSI?
thanks again for ur reply

regards

Parents
  • As I already explained once you write to SPDR it automatically transmits data to shift register and it is not seen in SPDR any more, try making 2 consecutive writes to SPDR.
    SPI is not simulated on bit level so MOSI and MISO pins are not really toggling depending on the data but instead virtual registers are used SPI_IN and SPI_OUT.
    So you can think of SPI_OUT as data that is sent and SPI_IN as data received.

Reply
  • As I already explained once you write to SPDR it automatically transmits data to shift register and it is not seen in SPDR any more, try making 2 consecutive writes to SPDR.
    SPI is not simulated on bit level so MOSI and MISO pins are not really toggling depending on the data but instead virtual registers are used SPI_IN and SPI_OUT.
    So you can think of SPI_OUT as data that is sent and SPI_IN as data received.

Children
  • Thanks for your reply.
    when i tried to run the following program i never got any value set in SPDR register at any point of time.

            while(1)
            {
                      LPC_SPI->SPDR = byte;
                      byte++;
                      while(!(LPC_SPI->SPSR & 0x80));
            }
    

    then i used the following simulation script for SPI_IN

    signal void spi_func (void) {
    while (1) {
      wwatch (SPI_OUT);
      printf ("SPI_OUT: %2.2X\n", (unsigned) SPI_OUT);
      SPI_IN = SPI_OUT + 1;
      }
    }
    


    with following program

                      LPC_SPI->SPDR=byte;
                      while(!(LPC_SPI->SPSR & 0x80));
                      byte=LPC_SPI->SPDR;
    

    I see the changes in SPDR whenever i am receiving data
    but not when sending the data.

    Thanks again for your reply.
    Regrads

  • I think you did not quite understand writing to SPDR register twice consecutively, that would mean

    LPC_SPI->SPDR = byte;
    LPC_SPI->SPDR = byte;