PSoC 3/5LP SPI-DMA 16-bit Operation – KBA223730

Version 2

    Version: **


    Translation - Japanese: PSoC 3/5LP SPI-DMA の 16-bit オペレーション - KBA223730 - Community Translated (JA)



    How do I configure PSoC® 3/5LP DMA for transferring or receiving 16-bit data?


    Answer: Use the SPI Master with DMA and SPI Slave with DMA code examples in PSoC Creator to get started.


    In PSoC Creator, select File > Code Example.  You can also search for relevant code examples with the keyword as “DMA” as Figure 1 shows. Similar to PSoC 5LP, PSoC 3 also has the same set of code examples.


    Figure 1. PSoC Creator SPI-DMA Code Examples


    The code example has data bits set to 8 bits. Do the following to change the SPI to 16-bit transfer.


    1. Change SPI data length to 16 from 8. See Figure 2.

    Figure 2: Configuring SPI Master Data Bits


      2. Change the DMA Burst length from 1 byte to two bytes. Go to main.c line 37. Modify the existing line to the following line.


    #define DMA_TX_BYTES_PER_BURST     (2u)


    Similarly, modify the burst length for all the DMA channels.


      3. Use the following defines as the SPI TX and RX pointers respectively.


           main.c line 145


    CyDmaTdSetAddress(txTD, LO16((uint32)txBuffer), LO16((uint32) SPIM_BSPIM_sR16_Dp_u0__16BIT_F0_REG));


          main.c line 179


    CyDmaTdSetAddress(rxTD, LO16((uint32) SPIM_BSPIM_sR16_Dp_u0__16BIT_F1_REG), LO16((uint32)rxBuffer));


    The pointer defines available with the SPIM Component is not compatible with 16-bit operation. Therefore, these register defines must be used for proper operation. For the SPIS_Example project, use an appropriate pointer similar to the SPIM Component pointer given in the code snippet.