Author Topic: DMA usage on the SAM7X  (Read 7506 times)

Offline lthyagar

  • Newbie
  • *
  • Posts: 21
    • View Profile
DMA usage on the SAM7X
« on: October 04, 2009, 05:34:50 PM »
Hello Mark, I was going through the DMA drivers for the USARTs. It looks like the drivers do not use the "Next counter" and "Next pointers" features, which causes the DMA to  re-enable the triggers, when the counter is decremented to zero. Is there a specific reason for not using this feature?
Thanks!!
Lav

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: DMA usage on the SAM7X
« Reply #1 on: October 06, 2009, 03:13:09 PM »
Hi Lav

The USART DMA driver doesn't make use of the next buffer capability. Generally this is not critical since it doesn't generally matter if there is a small gap between USART transmission (in ASYNC mode). The DMA saves individual character interrupts (its main advantage) but there is still an interrupt after each block (using the next buffer or not).

There are two optimisations that the use of the next buffer would make possible:

1) When a block of data is wrapped in the output buffer (that means that start of the block is up to the end of the circular buffer and the end is at the beginning of the circular buffer) it would be possible to set up two DMA buffers to automatically start transmission of the two parts of the block). Presently only the first part is sent as a block and the second part as a second block once the first block interrupt arrives.

2) When the application performs a second write during transmission of a block, the next buffer could be prepared so that it is started automatically when the first block completes.

However the disadvantage of this is certainly some increased complexity. Also the advantages are only theoretical since often the application will queue further data during which can not be added to the next buffer (already configured) and so the second block is smaller that it could have been (canceling original possible advantage).

This, in the case of ASYNC serial mode I don't think that there is a real need to use the next buffer capabilities.

Note that I have recently used the next buffer for DMA transmission and reception of SSC data. Here, where streaming is used and it is important to always have the next buffer ready to avoid data loss, it is an important feature. It is also very simple to use in this context (but less together with the UART circular buffer...)

Regards

Mark