1

While I'm not new to embedded programming, I'm new to the Atmel SAM3X microcontroller. I'm trying to figure out if it's possible to use DMA to read a value from a memory-mapped register (a GPIO port, in this case) into a buffer periodically at say 1/4 the clock rate (faster than can be accomplished by software copying or software triggering of DMA), then turn the buffer over to the USB DMA to send it out the USB cable.

I see that PWM is one of the peripherals that can perform DMAC "transmissions", and I also see that the DMA channel registers have separate spots for source address and source peripheral identifier. Are the address and peripheral identifier independent and potentially co-operational? Could you use PWM as the source peripheral as a clock divider but then copy from the port data address? If so, how might this be accomplished in terms of register writes (I ask to try to circumvent the need for trial and error); if not, is there any other way of sampling a memory location at regular high but sub-clock speeds?

Justin Olbrantz
  • 647
  • 3
  • 11
  • Does it need to be buffered? I can’t speak to the SAM3X, but other SAM devices can have a TC module copy from MMIO to a usart. I doubt it could happen at 1/4 clock speed, though. – Mitch Apr 15 '20 at 04:35
  • I believe it needs to be buffered as USB to any one peripheral is bursty and I want to sample at regular intervals even when the USB is not currently transmitting.. – Justin Olbrantz Apr 15 '20 at 04:40
  • Further information brings further confusion: PWM is a transmit (to) peripheral for BOTH the DMAC and PDC. It sounds like the purpose of DMA to PWM is to allow the duty cycle and update period to be updated via DMA, and the trigger is when the update period expires. This only makes the answer to my question less clear. – Justin Olbrantz Apr 16 '20 at 07:09
  • If you are trying to find an event, I believe you can use the Timer/Counter modules for that purpose. – Mitch Apr 16 '20 at 13:58
  • @mitch Does that work on SAM3X? I think that works on SAMD21, but I haven't found any simple way to do it on SAM3X without the kind of clever tricks I'm looking at here.(using the PWM synchronous update event to trigger memory copy then update the PWM period via DMA). – Justin Olbrantz Apr 17 '20 at 08:22
  • No. I agree. That seems to be missing on the 3X. Most of my experience is on the smaller lines like the SAMD21 and D11. – Mitch Apr 17 '20 at 14:51
  • I do remember reading that this is basically how the Saleae Logic analyzers are implemented. Probably not applicable to the SAM3X, but it might be a good touchstone. [Some discussion here](https://forum.43oh.com/topic/7367-designing-a-logic-analyser-using-gpio-dma-usb/) – Mitch Apr 17 '20 at 14:58
  • Aha. That's actually exactly what I'm trying to make - a USB logic analyzer. – Justin Olbrantz Apr 18 '20 at 03:13
  • The big reason I'm hesitant to "try it and find out" is that I don't know how to verify whether it's working if I try it, as I lack several tools that would be of use for this purpose (an emulator or a logic analyzer). It would be easy enough to see if the DMA is triggering AT ALL, and to send the data over USB, but how to verify that it's sampling the value regularly (not bursty) and at the rate I want? – Justin Olbrantz Apr 18 '20 at 04:11

0 Answers0