Hi
I don't know what is in the source code but the application note's code is incorrect.
PORTD_PCR7|=(0|PORT_PCR_MUX(1)|PORT_PCR_IRQC(0x1));
enables DMA trigger on a single edge whereby the description says it is needed on both edges.
Therefore probably a Typo in the code part of the document.
Note that the PIT DMA output method is integrated into the PIT driver in the uTasker project. The user interface just sets the PIT_OUTPUT_DMA_TRIG flag and the port(s) to be toggled and the rest is automated (generates 2 complimentary square wave outputs):
PIT_SETUP pit_setup; // PIT interrupt configuration parameters
pit_setup.int_type = PIT_INTERRUPT;
pit_setup.mode = PIT_PERIODIC;
pit_setup.count_delay = PIT_US_DELAY(500); // 500us period (1kHz)
pit_setup.mode = (PIT_PERIODIC | PIT_OUTPUT_DMA_TRIG); // periodic with DMA trigger to control a port toggle
pit_setup.ulPortBits = (PORTA_BIT1 | PORTA_BIT23); // toggle PTA1 and PTA23 on each PIT trigger
pit_setup.ucPortRef = PORTA;
pit_setup.ucPIT = 1; // use PIT1 (this will use DMA channel 1, 0 would use DMA channel 0, etc.)
pit_setup.int_handler = 0; // no interrupt due to DMA
_CONFIG_DRIVE_PORT_OUTPUT_VALUE(A, (PORTA_BIT1 | PORTA_BIT23), (PORTA_BIT1), (PORT_SRE_SLOW | PORT_DSE_HIGH)); // prepare port outputs for complimentary square wave
fnConfigureInterrupt((void *)&pit_setup); // configure PIT
This is however foreseen more for emergencies where other timers are not already available since the DMA transfer (when high frequencies are generated) can have a bus loading effect that is then noticeable due to sharing with other high speed peripherals (eg. it makes USB unreliable at above around 2MHz on KL parts), plus there is some jitter on the output.
Note also that the complete operation is simulated in the uTasker project so that it (including PIT and DMA) can be inspected in the simulation.
Regards
Mark