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: Question on communicating with MRF89XA RF module with SPI interface

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

Tool/software: Code Composer Studio

Hi all:

    I am now working on commnucating with MRF89XA module through SPI interface with Launchpad board.

    However, I meet some problems:

        1. The configuration of SPI interface on LaunchPad. I want to make sure the SPI interface is : 1MHz,8-bit, SPI mode 0 .

    GPIO_setPadConfig(DEVICE_GPIO_PIN_SPISIMOA,GPIO_PIN_TYPE_PULLUP);
    GPIO_setPinConfig(DEVICE_GPIO_CFG_SPISIMOA);
    GPIO_setQualificationMode(DEVICE_GPIO_PIN_SPISIMOA,GPIO_QUAL_ASYNC);

    //SCLK----GPIO56
    GPIO_setPadConfig(DEVICE_GPIO_PIN_SPICLKA,GPIO_PIN_TYPE_PULLUP);
    GPIO_setPinConfig(DEVICE_GPIO_CFG_SPICLKA);
    GPIO_setQualificationMode(DEVICE_GPIO_PIN_SPICLKA,GPIO_QUAL_ASYNC);

    //SOMI----GPIO17
    GPIO_setPadConfig(DEVICE_GPIO_PIN_SPISOMIA,GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(DEVICE_GPIO_CFG_SPISOMIA);
    GPIO_setQualificationMode(DEVICE_GPIO_PIN_SPISOMIA,GPIO_QUAL_ASYNC);

    //SPI_CS----GPIO39
    GPIO_setPinConfig(GPIO_39_GPIO39);
    GPIO_setPadConfig(39,GPIO_PIN_TYPE_PULLUP);
    GPIO_setDirectionMode(39,GPIO_DIR_MODE_OUT);

void initSPI_A()
{
// // Must put SPI into reset before configuring it. // SPI_disableModule(SPIA_BASE); // // SPI configuration. Use a 1MHz SPICLK and 8-bit word size,SPI mode 0 // SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0, SPI_MODE_MASTER, 1000000, 8); // // Configuration complete. Enable the module. // SPI_enableModule(SPIA_BASE); }

        2. The Interrupt mechanism:

            I am not sure  that the write and read function are correct. In "ReadData" function, thr for loop confused me so much. Why do you add  "SPI_writeDataBlockingNonFIFO(SPIA_BASE, 0x0000)" to "Send dummy data to receive the EEPROM data". Is this step necessary?? and what does it for? 

            My peripheral is a RF module but not an eeprom, I have checked the data sheet of RF module,maybe the step "Send dummy data to receive the EEPROM data" is not necessary?

 

void readData(uint16_t address, uint16_t * data, uint16_t length)
{
    uint16_t i;

    CSCON_TXLOW;
    //
    // Send the MSB of the address of the EEPROM
    //
    /*
    SPI_writeDataBlockingNonFIFO(SPIA_BASE, (address & 0xFF00));

    //
    // Dummy read to clear INT_FLAG.
    //
    SPI_readDataBlockingNonFIFO(SPIA_BASE);
*/
    //
    // Send the LSB of the address of the EEPROM
    //
    SPI_writeDataBlockingNonFIFO(SPIA_BASE, (address<<8) );

    //
    // Dummy read to clear INT_FLAG.
    //
    SPI_readDataBlockingNonFIFO(SPIA_BASE);

    //
    // Read the data from the EEPROM
    //
    for(i = 0; i < length; i++)
    {
        //
        // Send dummy data to receive the EEPROM data
        //
        SPI_writeDataBlockingNonFIFO(SPIA_BASE, 0x0000);
        data[i] = SPI_readDataBlockingNonFIFO(SPIA_BASE);
    }

    CSCON_TXHIGH;
}

    3. I am always blocking here while Debug:

  

      When I check the datasheet, I find the INT_FLAG should be 1 when transmitting or receiving completely,  I think I have successfully send the data but why the "INT_FLAG" not be 1.

  • Li,

    Why do you add  "SPI_writeDataBlockingNonFIFO(SPIA_BASE, 0x0000)" to "Send dummy data to receive the EEPROM data". Is this step necessary?? and what does it for? 

    To receive data, the SPI master is mandated to transmit dummy data to initiate SPI transfer. It is part of SPI protocol and how it functions.

    Did you probe your SPI pins to check whether SPI is transmitting and receiving? Are readData and writeData functions written by you (or) are you using TI example functions? It is quite possible that MRF89XA doesn't recognize the commands you are sending. So, make sure to check MRF89XA datasheet in what format it expects for proper communication.

    Did you already check spi_ex5_external_loopback_fifo_interrupts example project in C2000Ware which shows how to configure SPI in master mode in below path?

    <C2000Ware<\driverlib\f28004x\examples\spi

    Regards,

    Manoj