AnsweredAssumed Answered

SPIF always set

Question asked by Dano on Nov 15, 2010
Latest reply on Jan 6, 2011 by Dano



I trying to use the BF 506F SPI1 in the simplest way possible, where I am polling the SPIF bit.

However, it seems that this bit is always set even before I transmit anything out.


Here is my code. What's wrong?


*pPORTG_FER  = 0xFFFF;         // Port G enable
*pPORTG_MUX  = 0x0000;         // Port G SPI Slaves
*pSPI1_FLG        = FLS3;            // Slave select 3
*pSPI1_BAUD     = 0xFF;            // Set Baud rate
*pSPI1_CTL         = RDBR_CORE | CPHA | MSTR | SPE;

*pSPI1_FLG &= ~0x0800;            // slave select 3 active
*pSPI1_TDBR = 0x1234;              // transmit first byte

*pSPI1_RDBR;                              // dummy read

while (!(*pSPI1_STAT & SPIF)) {};  // Poll SPIF. This is where SPIF is already set
*pSPI1_FLG |= 0x0800;              //  deselect slave 3