AnsweredAssumed Answered

Why do I lost one byte from SPI?

Question asked by dinrail on Jul 17, 2013
Latest reply on Jul 19, 2013 by dinrail

The SPI example folder is empty so I gave it a try with the following codes. I thought I created 3 bytes in Tx FIFO, so when I flush the FIFO, write two bytes in a roll via SpiTx, then wait, I should see the two bytes sent out on SPI bus, but I saw only one, the second one is lost. Why?


void SPI0INIT (void)


    pADI_GP1->GPCON = (pADI_GP1->GPCON&0x00ff)|0xaa00;



    ,0  //baud rate is SPI UCLK/2x(iCLKDiv+1).

    ,SPIDIV_BCRST_DIS  //disable CS error detection




    SPICON_MOD_TX3RX3, //Rx and Tx FIFO sizes.

    SPICON_MASEN_EN, //enable SPI in Master mode.

    SPICON_CON_ED //enable continuous transfer

    |SPICON_TIM_TXWR //Initiate transfer with a write to the SPI TX register

    |SPICON_CPOL_HIGH //Serial clock idles high

    |SPICON_CPHA_SAMPLETRAILING //Serial clock pulses at the  start of the first data bit transfer

    |SPICON_ENABLE_EN //enable of the SPI peripheral




main ()




    ClkSel(CLK_CD7,CLK_CD7,CLK_CD0,CLK_CD7);     // Select CD0 for UART System clock




    while (1){


        SpiTx(pADI_SPI0, 0x55);

        SpiTx(pADI_SPI0, 0xAA);

        for (jj=0; jj<10000; jj++){





*I tried both SPICON_CON_EN and SPICON_CON_DIS, SPICON_MOD_TX3RX3 and SPICON_MOD_TX2RX2,  and the result is the same