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.

Variable length SPI & DMA

Other Parts Discussed in Thread: MSP430F5438

I'm receiving packets via an SPI slave of variable length.  My wish is to enter low power mode until the packet completes.

I've setup the DMA as 'repeat single transfer' mode triggering on the SPI rx with a maximum buffer length in the DMAxSZ register.  The MSP430 is interrupted by an outside source when the last character is complete. Everthing works very well; all data is received via the SPI and stored properly in the reception buffer.

My problem is that I don't know how many characters were received.  The DMA module knows both the number of characters received and the next position in the buffer, but no matter how hard I twist his skinny little pins, it won't give me the information.

Has anyone any ideas?

 

 

 

  • I didn't see in your post what specific device you were using.  My response is based on the MSP430x2xx Family which is described in the MSP430x2xx Family User's Guide.

    In Chapter 6, which described the DMA controller, Figure 6-3 illustrates a DMA Single Transfer State Diagram.  In this diagram, is indicates DMAxSZ is originally set with the maximum size of the transfer which you indicated you have done.  This is also stored into a temporary register, which is not readable by the CPU, for the purpose of reloading the DMAxSZ register once it decrements to 0.  In addition, for each trigger event, the DMAxSZ is decremented.  You should be able to read this register once you receive the interrupt from the outside source indicating end of bulk transfer.  The difference between the original programmed value of DMAxSZ and the current DMAxSZ value would provide you with the information regarding how many characters were in fact received.

    Are you able to observe this behavior?

  • Thank you, Brandon.

    I was using DMA repeated single transfer mode (not what I desired) on the MSP430F5438.  After switching to the DMA Single Transfer Mode,  as noted in your message, I now see the change in the DMAxSZ register.

    Thanks to your help, I'm now good to go!

**Attention** This is a public forum