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.

CC1312R: SPI DMA implementation - any examples?

Part Number: CC1312R


Hello,

is there any example of how to use DMA in SPI communication?

Greetings,

Michal

  • The SPI driver in the SDK uses the DMA:

    SPICC26X2DMA.h File Reference (ti.com)

    Siri

  • Ok thanks. 

    Is there any ready to go application example? Or just SDK you've sent?

    Michal

  • The SPI examples in the SDK uses the SPI driver:

    TI Drivers

    Siri

  • Hello. 

    This SDK seems to be working fine except there is an issue that RX buffer is not filled with any data. I checked MOSI and MISO lines with Logic Analyzer and transmission is good - all bytes are transmitted. 

    What could be the problem? 

    Transfer is configured like that:

      SPI_Transaction transaction;
    
      /* Initialize master SPI transaction structure */
      transaction.count = len;
      transaction.txBuf = (void*)spiTempTxBuf;
      transaction.rxBuf = (void*)spiTempRxBuf; //buf;
    
      /* Perform SPI transfer */
      bool retVal = SPI_transfer( dmaSpi, &transaction );

  • I am not sure I understand what you mean? are you testing the default spicontroller and spiperipheral example in the SDK and it does not receive? How can it then "be working fine"?

    If the default example is not working, please describe exactly how you are connecting your boards, what is displayed on the UART etc.

    If you have made changes to the examples, you need to provide us with all of the changes so that we can try to reproduce the problems on our LPs to see what is going on.

    Siri

  • Hi. 

    The transmission itself seems to be working fine because I can see on logic analyzer all bytes are transferred both ways (from Master to Slave, and from Slave to Master). 

    But RX buffer which is spiTempRxBuf here is not filled with any data. Not even a single byte.

    I did not use example. I just use SPI driver library from SDK 6.10.00.29 (cc13xx_cc26xx)

  • If you do not use our example, I cannot tell you why your code is not working when I do not know know what you are doing in your code, what HW you are running on, or even how you are connecting your boards.

    If you have a code example that runs on our LPs and using our drivers etc. I can try it here, but you need to share your code.

    Siri

  • Hi, try using the cache.

  • hi, what do you mean by using the cache? 

  • I am using LAUNCHXL-CC1312R1. 
    Code I use is straight from example "nvsexternal"

        NVS_Handle nvsHandle;
        NVS_Attrs regionAttrs;
        NVS_Params nvsParams;
    
        NVS_init();
        NVS_Params_init(&nvsParams);
        nvsHandle = NVS_open(CONFIG_NVSEXTERNAL, &nvsParams);
    
        if (nvsHandle == NULL)
        {
          LOG( LOG_RAW, LOG_INFO, LOG_MASK_UNSPEC | LOG_MASK_PASSIVE, "memory open fail\n" );
        }
    
        /*
         * This will populate a NVS_Attrs structure with properties specific
         * to a NVS_Handle such as region base address, region size,
         * and sector size.
         */
        NVS_getAttrs(nvsHandle, &regionAttrs);
    
        /*
         * Copy "sizeof(signature)" bytes from the NVS region base address into
         * buffer.
         */
        int16_t returnValue = NVS_read(nvsHandle, 0, (void *)buffer, sizeof(signature));
        if( returnValue == NVS_STATUS_SUCCESS )
        {
          LOG( LOG_RAW, LOG_INFO, LOG_MASK_UNSPEC | LOG_MASK_PASSIVE, "Read SPI flash OK");
        }
    
        /*
         * Determine if the NVS region contains the signature string.
         * Compare the string with the contents copied into buffer.
         */
        if (strcmp((char *)buffer, (char *)signature) == 0)
        {
    
          /* Write buffer copied from flash to the console. */
          LOG( LOG_RAW, LOG_INFO, LOG_MASK_UNSPEC | LOG_MASK_PASSIVE, "%s", buffer);
          LOG( LOG_RAW, LOG_INFO, LOG_MASK_UNSPEC | LOG_MASK_PASSIVE, "Erasing SPI flash sector...");
    
          /* Erase the entire flash sector. */
          NVS_erase(nvsHandle, 0, regionAttrs.sectorSize);
        }
        else
        {
    
          /* The signature was not found in the NVS region. */
          LOG( LOG_RAW, LOG_INFO, LOG_MASK_UNSPEC | LOG_MASK_PASSIVE, "Writing signature to SPI flash...");
    
          /*
           * Write signature to memory. The flash sector is erased prior
           * to performing the write operation. This is specified by
           * NVS_WRITE_ERASE.
           */
          NVS_erase(nvsHandle, 0, regionAttrs.sectorSize);
          NVS_write(nvsHandle, 0, (void *)signature, sizeof(signature), NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
        }

  • I am afraid I really do not understand exactly what you are experiencing problems with or how I can help you.

    You were asking about the SPI + DMA and I referred you to our SPI driver.

    Than you claimed there were issues with it (data not being put in the spiTempRxBuf), and I asked you about your code/how you were using it so that I could look into it.

    Then you are suddenly referring to the  nvsexternal example, which uses the NVS driver, and you post the example (almost identical to our example), but you are not saying what problems you are facing.

    If you have problems with the SPI driver, please post the example that will recreate the issues with the SPI driver on our LP, and give me an explanation as to what I should look for (in that example). What exactly is not working.

    Same thing for NVS;

    If you have problems with the NVS driver, please post the example that will recreate the issues with the NVS driver on our LP, and give me an explanation as to what I should look for (in that example). What exactly is not working.

    I am sorry that I cannot help you more at this point.

    Siri