AnsweredAssumed Answered

BF609 SPI RFIFO error

Question asked by sharath@delopt.co.in on Feb 19, 2015
Latest reply on Feb 23, 2015 by Prashant

I am struggling with receiving data from SPI RFIFO register. The following is the code snippet that is used to receive data from SPI

 

  *pREG_SPI0_CTL &= ~(ENUM_SPI_CTL_DIS);

  *pREG_SPI0_SLVSEL &= ~(ENUM_SPI_SLVSEL_SSEL3_HI);    // Select device

  *pREG_SPI0_TWC = 2;

  *pREG_SPI0_TXCTL = (ENUM_SPI_TXCTL_TX_EN | ENUM_SPI_TXCTL_TTI_EN | ENUM_SPI_TXCTL_TWC_EN);

 

  *pREG_SPI0_CTL |= ENUM_SPI_CTL_EN;

    buf = 0x98;

 

    while((*pREG_SPI0_STAT & BITM_SPI_STAT_TFF));

       *pREG_SPI0_TFIFO = buf;

 

       *pREG_SPI0_RWC = 1;

     *pREG_SPI0_RXCTL = (ENUM_SPI_RXCTL_RX_EN | ENUM_SPI_RXCTL_RTI_EN | ENUM_SPI_RXCTL_RWC_EN );//| ENUM_SPI_RXCTL_OVERWRITE);

     *pREG_SPI0_TFIFO = 0xFF;    // Dummy write to provide SCLK

 

     while(!(*pREG_SPI0_STAT &  (BITM_SPI_STAT_RF |BITM_SPI_STAT_TF)));

     readByte = *pREG_SPI0_RFIFO;

 

    //while(!(*pREG_SPI0_STAT & BITM_SPI_STAT_RFE));

   //   readByte = *pREG_SPI0_RFIFO;           // Get byte from SPI register

 

      *pREG_SPI0_STAT = BITM_SPI_STAT_RF | BITM_SPI_STAT_TF;

      *pREG_SPI0_SLVSEL |= ENUM_SPI_SLVSEL_SSEL3_HI;    // Select device

      *pREG_SPI0_RXCTL = 0;

      *pREG_SPI0_RWC = 0;

      *pREG_SPI0_TXCTL = 0;

 

  return readByte;                 // Return the read byte

Outcomes