DMAChannel::triggerAtHardwareEvent digital pin source?

Status
Not open for further replies.

Markk

Well-known member
Hi

It's amazing how simple solutions have generally become with DMAChannel. Great work and thank you!

Still I'm stuck here: I tried to find out if a digital pin input (edge) can trigger a DMA transfer (random pulses from outside, not periodic).

NOTE: I know I can trigger DMA from the comparators, but I've already used up those.

I've looked at the DMAChannel source code and examples as well as the K20 datasheet but it still eludes me, how this all works.

The most promising was this: https://github.com/PaulStoffregen/OctoWS2811/blob/master/OctoWS2811.cpp:
Code:
        // pin 16 triggers DMA(port B) on rising edge (configure for pin 3's waveform)
	CORE_PIN16_CONFIG = PORT_PCR_IRQC(1)|PORT_PCR_MUX(3);
But: if I look at the K20 Signal Multiplexing and Pin Assignments "ALT3" mapping (which I assume is enabled by PORT_PCR_MUX(3)) for Pin 16 (which is K20 Pin 35) I see it is mapped to FTM1_CH0, the underlying timer that (I guess) was prepared using the analogWrite/PWM setup. It isn't the pin at all (is it?). Now I'm completely confused... also I don't understand the ports A, B, C...

Is there a way for digital inputs' DMA triggering at all?

Thanks for all help!
-Markk
 
Code:
PORTA_PCR13 |= PORT_PCR_IRQC(2);
OR
CORE_PIN4_CONFIG = PORT_PCR_IRQC(2)
Enables portA pin13 to generate a DMA request on a falling edge. Check PORTx_PCRn in the datasheet for details.

Have a look at this schematic to see what pins connect to which ports on the MCU
schematic32.gif
As you can see PTA13 or PortA Pin 13 is connected to the Teensy's Pin 4

If you use:
Code:
dmachannel.triggerAtHardwareEvent(DMAMUX_SOURCE_PORTA);

This will cause the dmachannel to trigger when a request is made by PortA. In this case that is Pin 13 as we enabled earlier.


Check my thread over here for sample code if you need it
 
Last edited:
Often, a pin change is used to cause a timer's capture value for that pin to be DMA'd to a buffer. After X samples or Y time, the application can process the buffer.
To, say, measure frequency or pulse period of a fast-changing nature.
Time-tag when each pin change occurred. If the changes are relatively slow, it's probably easier to use a pin change interrupt rather than DMA.
 
Check my thread over here for sample code if you need it

Very nice!

The K20 datasheet is really cryptic...

A more detailed description of the capability of each trigger, including resolution, range
of values, and so on, may be found in the periodic interrupt timer section.
The PIT module is an array of timers that can be used to raise interrupts and trigger DMA
channels.
I really believed only timers [and IO modules] can actually trigger them...

Thank you guys.

-Markk
 
Success!

Just wanted to report that it works like a charm. Thanks to Xenoamor again!
 
Status
Not open for further replies.
Back
Top