.
There is an external trigger signal for an interrupt that run a function where I do a memcpy to copy the DMA buffer to an array. I think it's here, when I do the memcpy, I lose some data, but I'm not sure if DMA was not so fast to capture all the data or if my program does not arrive in time to copy the data from the DMA buffer. After optimizing the source code, I managed to improve it a lot, but not totally, the result is now acceptable, but not perfect.
At any rate with same source code, works fine with Teensy 3.6, even at 144Mhz, but fail with Teensy 3.5 even with 168Mhz overclock. With Teensy 3.6 at 120Mhz also fail. The strange is that with same clock frequency, 144 or 168 Mhz, works with Teensy 3.6, and fail with Teensy 3.5.
Source code to Configure interrupt to copy the DMA buffer to a work array.
attachInterrupt(digitalPinToInterrupt(DMD_ROW_DATA), portb_isr_spike, RISING); // Inicio de FRAME
attachInterrupt(digitalPinToInterrupt(DMD_DOT_LATCH), portb_isr_spike, RISING); // Inicio de Linea, OK.
attachInterruptVector(IRQ_PORTB, portb_isr_spike); // Replace global PORTB isr
Part of the Source code in the interrupt function to copy DMA buffer
// Captura datos de linea (128 puntos) por DMA
memcpy(wpc_planes[plane][row], plane_buffer, 16); // Copia buffer DMA a matriz planos
digitalWriteFast(DMD_CS, HIGH); // Use fake chip select to end plane
// Reinicia DMA para siguiente captura de linea
// Flush the receive buffer, in case we're out of sync
SPI0_MCR |= SPI_MCR_HALT;
SPI0_MCR |= SPI_MCR_CLR_RXF;
// Reset the DMA transfer
dmaSPI0rx->disable();
dmaSPI0rx->clearComplete();
dmaSPI0rx->destinationBuffer(plane_buffer, 16);
dmaSPI0rx->enable();
// Start new SPI plane
SPI0_MCR &= ~SPI_MCR_HALT;
digitalWriteFast(DMD_CS, LOW);