This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-F280049C: QUESTIONS ON SPI EXAMPLE CODE

Part Number: LAUNCHXL-F280049C
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hi all:

     I am now trying to modify the SPI example code which is "C2000_LAUNCHPAID\software_install\C2000Ware_3_02_00_00\driverlib\f28004x\examples\spi\spi_ex4_eeprom.c".

     I don't very undestand these three functions which are "readStatusRegister()" and "SPI_writeDataBlockingNonFIFO", "SPI_readDataBlockingNonFIFO".

     What do these functions for?  If I don't use these functions, what kinds of errors will occur? Do the "readStatusRegister()" just for checking the SPI bus is busy or not? or check the INT_FLAG?

Also, I don't really understand these marcons for(see below). I don't find them in datasheet.

#define RDSR                        0x0500
#define READ                        0x0300
#define WRITE                       0x0200
#define WREN                        0x0600
#define WRDI                        0x0400
#define WRSR                        0x0100

uint16_t readStatusRegister(void)
{
    uint16_t temp;

    //
    // Pull chip select low.
    //
    CSCON_TXLOW;

    //
    // Send RDSR opcode
    //
    SPI_writeDataBlockingNonFIFO(SPIA_BASE, RDSR);

    //
    // Dummy read to clear INT_FLAG.
    // spi read rxbuf will clear INT_FLAG
    temp = SPI_readDataBlockingNonFIFO(SPIA_BASE);

    //
    // Send dummy data to receive the status.
    //
    SPI_writeDataBlockingNonFIFO(SPIA_BASE, 0x0000);

    //
    // Read status register.
    //
    temp = SPI_readDataBlockingNonFIFO(SPIA_BASE);

    //
    // Pull chip select high.
    //
    CSCON_TXHIGH;

    //
    // Read the status from the receive buffer
    //
    return(temp);
}

     If I just want communicate peripherals through SPI with non-FIFO, what should I modify in example code?

  • Hi Xingyu Li,

    This example is written for the Serial EEPROM AT25128/256. The macros are the opcodes required by the EEPROM for various operations such as read, write etc.

    readStatusRegister function is used to send the opcode to the EEPROM to read its status register contents. Please refer to the EEPROM datasheet for more details regarding the opcodes used.

    SPI_writeDataBlockingNonFIFO and SPI_readDataBlockingNonFIFO are SPI driverlib functions used to send and receive SPI data without using the FIFO. You may refer to the driverlib SPI user guide for more details regarding the driverlib functions.

    You may refer to other examples in spi folder to see how SPI to SPI communication can be done with and without using FIFOs

    Regards,

    Veena