AnsweredAssumed Answered

Problem with PIT triggered DMA ...

Question asked by Paul Swanson on Jul 27, 2019
Latest reply on Jul 28, 2019 by Paul Swanson

Hello,

 

Working with a FRDM-KL25Z board (MKL25Z128VLK4 mcu) and mostly just CMSIS with some boilerplate code from Freescale.

 

What I'm wanting to achieve right now is this:

  1. PIT Timer triggers a single (32bit) DMA memory to memory transfer
  2. That transfer causes the toggling of a GPIO pin

The goal here is to achieve a periodic toggling of a GPIO pin with interrupting the main loop or requiring an interrupt handler to be called. In other words, a blinky LED using just the PIT, DMA and GPIO ... no CPU, no interrupt handlers.

 

 I've no problem getting the PIT timer going. But right now, I can't seem to get the DMA transfer to happen as a result of the PIT timer expiring.

 

Here's a sample of the source code (just using CMSIS and some other boilerplate code from Freescale not shown here):

 

#define LED1 7
const uint32_t LED1_DMA = (1UL << LED1);


// Configure clock for PORTC, DMA Multiplexer, DMA & PIT
SIM->SCGC5 |= SIM_SCGC5_PORTC(1);
SIM->SCGC6 |= SIM_SCGC6_DMAMUX(1) | SIM_SCGC6_PIT(1);
SIM->SCGC7 |= SIM_SCGC7_DMA(1);

 

// Disable DMAMUX channel and PIT timer
DMAMUX0->CHCFG[0] = 0;
PIT->CHANNEL[0].TCTRL &= ~PIT_TCTRL_TEN(1);

 

// Configure DMA Source and Destination addresses
DMA0->DMA[0].SAR = (uint32_t)&LED1_DMA;
DMA0->DMA[0].DAR = (uint32_t)&PTC->PTOR;
DMA0->DMA[0].DCR = DMA_DCR_ERQ(1) | DMA_DCR_CS(1);

 

// Configure PIT
PIT->CHANNEL[0].LDVAL = SystemCoreClock - 1; // 47999999 or one second
PIT->CHANNEL[0].TCTRL |= PIT_TCTRL_TEN(1) | PIT_TCTRL_TIE(1);
PIT->MCR = 0; /* Module enabled, don't freeze in debug */

 

// Enable DMAMUX0 Channel 0, always on and triggered
DMAMUX0->CHCFG[0] |= 60 | DMAMUX_CHCFG_ENBL(1) | DMAMUX_CHCFG_TRIG(1);

 

/* Set Port C Pin 7 to GPIO module */
PORTC->PCR[LED1] &= ~PORT_PCR_MUX_MASK; /* Clear MUX bits */
PORTC->PCR[LED1] |= PORT_PCR_MUX(1); /* Enable pin 7 for GPIO */
PTC->PDDR |= (1UL << LED1); /* Set pin 7 to output */
PTC->PCOR |= (1UL << LED1); /* Set pin 7 low */

 

My understanding is that PIT timer should triggering a DMA transfer of a single 32bit word, as configure, by this stage and that resulting in a GPIO pin toggling (blinking LED) once per second. The PIT is going, but the DMA module is doing nothing.

 

Any assistance would be greatly appreciated.

 

Regards,

 

Paul Swanson

Outcomes