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.

MSP432 DMA, how to trigger spi dma transfer upon an input change ?

Hi all,

I'm interfacing an external ADC with an MSP432 (actually with the launchpad).

I'm able to use DMA with SPI to read the conversions of the ADC. But I start the transfers manually each time I receive an input change interrupt from the conversion ready line of the ADC. 

Is there a way to setup the DMA to trigger automatically upon that change instead of having to go in an interrupt and having code enabling the transfer ?

Thank you,

Jean-Michel

  • Hi Jean-Michel,

    It sounds like you want to have the DMA trigger off of the ADC having data ready in order to do a DMA transfer, right? Looking in the datasheet for the device, www.ti.com/.../msp432p401r Table 6-8 has a table of DMA trigger sources. You can see that the ADC14 is only listed for Channel 7 of the DMA, so you need to set it up to use DMA channel 7. It shows that for channel 7 to use the ADC14 trigger, you'll also need to se SRCCFG = 7. So you'll need to modify your code to use these settings. After you set it up correctly, you shouldn't need an ADC interrupt anymore so you can disable it because the DMA should trigger automatically.

    For an example of using the DMA with something other than software trigger, you may want to see this driverlib example: dev.ti.com/.../
    In that example, they set up two different DMA channels for two different triggers. You'll want to do something similar, but set your DMA up to use Channel 7 for ADC14.

    I hope this helps to give you some ideas of how to proceed.

    Regards,
    Katie
  • No I am not using the internal ADC.
    I am using an external ADC (MAX11214) which has a conversion ready line.

    Looking at the table you mentioned, could that be DMAE0 (external pin) on DMA channel 6 ? How do you use this one ?
  • Jean michel LECONTE1 said:
    No I am not using the internal ADC.
    I am using an external ADC (MAX11214) which has a conversion ready line.

    Looking at the table you mentioned, could that be DMAE0 (external pin) on DMA channel 6 ? How do you use this one ?

    Ah ok I misunderstood before and thought you were using the internal ADC14.
    Yes, you would want to configure the DMA channel 6 for the DMAE0 external pin. You would still probably reference the same example I mentioned above if you want to see how driverlib can set up DMA triggers, but in this case you'll need to set it up for channel 6 and SRCCFG = 7. As you see in the driverlib example, this can be done with some mnemonics instead when using driverlib (e.g. http://dev.ti.com/tirex/#/?link=MSPWare%2FLibraries%2FDriver%20Library%2FMSP432P4xx%2FExamples%2FDMA%2Fdma_eusci_i2c_loopback example uses     MAP_DMA_assignChannel(DMA_CH2_EUSCIB1TX0); but you would instead use MAP_DMA_assignChannel(DMA_CH6_EXTERNALPIN);  - you'd have to replace all references in the code with this).
    In addition to changing the channel and trigger source, the external pin trigger for DMA also requires an additional step - you need to correctly configure the GPIO on the device to be used for this function. If you look at the device Pin Diagrams shown in Chapter 4 of the datasheet, you can see that with default port mapping the DMAE0 signal is mapped to the P7.0 pin. Because it's available from the port mapping module, you could configure DMAE0 to be on any of the port mapped pins, meaning any pin on Port 2, Port 3, or Port 7. If you use the default port mapping (DMAE0 on P7.0) you'll simply have to see Table 6-38 in the datasheet that shows you can select DMAE0 function on this pin by setting P7DIR BIT0 to 0, P7SEL1 BIT0 to 0, and P7SEL0 to 1. If you want to use a different port mapped pin, you'll do the same type of setting on that pin, but additionally you'll then have to use the Port Mapping controller module to re-configure the port mapping and set the pin to be mapped for PM_DMAE0. There is a port mapping (PMAP) example in driverlib as well:
    Regards,
    Katie
  • I had time to finally try this solution and it does not seem to work.

    I setup the dma channel to transfer 4 bytes (I need to send one command byte, followed by 3 dummy bytes in order to read one 24-bit register of the ADC). Unfortunately it seems that the dma keeps copying in the peripheral buffer WITHOUT checking if the peripheral is still busy, and then I end up with 2 bytes transferred ( I guess that is dependent on the SPI speed). So with the same code, triggering on DMA_CH2_EUSCIB1TX0 works fine (all my bytes are transferred), whereas triggering on DMA_CH6_EXTERNALPIN only transfer few of the bytes.

    Any clue ?
  • Hi Jean Michel,

    Yes the DMA transfer is pretty much just a data bus transfer that you can have happen automatically, so it doesn't do any checking other than being triggered off of a signal - this is true of most DMAs on devices. If you want, you can have your DMA trigger off of the EUSCIB1TX0 signal as you said, because that signal is based off of the eUSCI B1 TXIFG flag which signals that the transmission buffer is ready to receive a new byte. In that case, however, you wouldn't be sure if your ADC data is ready, correct? Because in that case, DMA is only checking the TX flag and not the external signal that you are getting that says the ADC data is ready. It would depend on how your external ADC works if this is a good idea or not. The DMA can only check one thing for its trigger, not 2 conditions together as it sounds like you might need. It is going to be up to you to determine what is your best option based on your specific application requirements for this transfer, because you know the details of what your application is supposed to be doing. If you really need to check both signals (sounds like you might) then you may need to use a software trigger as you were before and have your software do the checking.

    Regards,
    Katie
  • I ended up using an interrupt on the conversion ready line of my adc which starts the 4 bytes spi dma transfer.

**Attention** This is a public forum