<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problem with PIT triggered DMA ... in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Problem-with-PIT-triggered-DMA/m-p/914881#M53555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Working with a FRDM-KL25Z board (MKL25Z128VLK4 mcu) and mostly just CMSIS with some boilerplate code from Freescale.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;What I'm wanting to achieve right now is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;PIT Timer triggers a single (32bit) DMA memory to memory transfer&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;That transfer causes the toggling of a GPIO pin&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;&amp;nbsp;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Here's a sample of the source code (just using CMSIS and some other boilerplate code from Freescale not shown here):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;#define LED1 7&lt;BR /&gt;const uint32_t LED1_DMA = (1UL &amp;lt;&amp;lt; LED1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;BR /&gt;// Configure clock for PORTC, DMA Multiplexer, DMA &amp;amp; PIT&lt;BR /&gt;SIM-&amp;gt;SCGC5 |= SIM_SCGC5_PORTC(1);&lt;BR /&gt;SIM-&amp;gt;SCGC6 |= SIM_SCGC6_DMAMUX(1) | SIM_SCGC6_PIT(1);&lt;BR /&gt;SIM-&amp;gt;SCGC7 |= SIM_SCGC7_DMA(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;// Disable DMAMUX channel and PIT timer&lt;BR /&gt;DMAMUX0-&amp;gt;CHCFG[0] = 0;&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].TCTRL &amp;amp;= ~PIT_TCTRL_TEN(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;// Configure DMA Source and Destination addresses&lt;BR /&gt;DMA0-&amp;gt;DMA[0].SAR = (uint32_t)&amp;amp;LED1_DMA;&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DAR = (uint32_t)&amp;amp;PTC-&amp;gt;PTOR;&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DCR = DMA_DCR_ERQ(1) | DMA_DCR_CS(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;// Configure PIT&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].LDVAL = SystemCoreClock - 1; // 47999999 or one second&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].TCTRL |= PIT_TCTRL_TEN(1) | PIT_TCTRL_TIE(1);&lt;BR /&gt;PIT-&amp;gt;MCR = 0; /* Module enabled, don't freeze in debug */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;// Enable DMAMUX0 Channel 0, always on and triggered&lt;BR /&gt;DMAMUX0-&amp;gt;CHCFG[0] |= 60 | DMAMUX_CHCFG_ENBL(1) | DMAMUX_CHCFG_TRIG(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;/* Set Port C Pin 7 to GPIO module */&lt;BR /&gt;PORTC-&amp;gt;PCR[LED1] &amp;amp;= ~PORT_PCR_MUX_MASK; /* Clear MUX bits */&lt;BR /&gt;PORTC-&amp;gt;PCR[LED1] |= PORT_PCR_MUX(1); /* Enable pin 7 for GPIO */&lt;BR /&gt;PTC-&amp;gt;PDDR |= (1UL &amp;lt;&amp;lt; LED1); /* Set pin 7 to output */&lt;BR /&gt;PTC-&amp;gt;PCOR |= (1UL &amp;lt;&amp;lt; LED1); /* Set pin 7 low */&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Any assistance would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Paul Swanson&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Jul 2019 01:50:11 GMT</pubDate>
    <dc:creator>q1220200</dc:creator>
    <dc:date>2019-07-28T01:50:11Z</dc:date>
    <item>
      <title>Problem with PIT triggered DMA ...</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Problem-with-PIT-triggered-DMA/m-p/914881#M53555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Working with a FRDM-KL25Z board (MKL25Z128VLK4 mcu) and mostly just CMSIS with some boilerplate code from Freescale.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;What I'm wanting to achieve right now is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;PIT Timer triggers a single (32bit) DMA memory to memory transfer&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="border: 0px; font-weight: inherit; margin: 0.5ex 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;That transfer causes the toggling of a GPIO pin&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;&amp;nbsp;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Here's a sample of the source code (just using CMSIS and some other boilerplate code from Freescale not shown here):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;#define LED1 7&lt;BR /&gt;const uint32_t LED1_DMA = (1UL &amp;lt;&amp;lt; LED1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&lt;BR /&gt;// Configure clock for PORTC, DMA Multiplexer, DMA &amp;amp; PIT&lt;BR /&gt;SIM-&amp;gt;SCGC5 |= SIM_SCGC5_PORTC(1);&lt;BR /&gt;SIM-&amp;gt;SCGC6 |= SIM_SCGC6_DMAMUX(1) | SIM_SCGC6_PIT(1);&lt;BR /&gt;SIM-&amp;gt;SCGC7 |= SIM_SCGC7_DMA(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;// Disable DMAMUX channel and PIT timer&lt;BR /&gt;DMAMUX0-&amp;gt;CHCFG[0] = 0;&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].TCTRL &amp;amp;= ~PIT_TCTRL_TEN(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;// Configure DMA Source and Destination addresses&lt;BR /&gt;DMA0-&amp;gt;DMA[0].SAR = (uint32_t)&amp;amp;LED1_DMA;&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DAR = (uint32_t)&amp;amp;PTC-&amp;gt;PTOR;&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DCR = DMA_DCR_ERQ(1) | DMA_DCR_CS(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;// Configure PIT&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].LDVAL = SystemCoreClock - 1; // 47999999 or one second&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].TCTRL |= PIT_TCTRL_TEN(1) | PIT_TCTRL_TIE(1);&lt;BR /&gt;PIT-&amp;gt;MCR = 0; /* Module enabled, don't freeze in debug */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;// Enable DMAMUX0 Channel 0, always on and triggered&lt;BR /&gt;DMAMUX0-&amp;gt;CHCFG[0] |= 60 | DMAMUX_CHCFG_ENBL(1) | DMAMUX_CHCFG_TRIG(1);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; padding: 0px 0px 0px 30px;"&gt;/* Set Port C Pin 7 to GPIO module */&lt;BR /&gt;PORTC-&amp;gt;PCR[LED1] &amp;amp;= ~PORT_PCR_MUX_MASK; /* Clear MUX bits */&lt;BR /&gt;PORTC-&amp;gt;PCR[LED1] |= PORT_PCR_MUX(1); /* Enable pin 7 for GPIO */&lt;BR /&gt;PTC-&amp;gt;PDDR |= (1UL &amp;lt;&amp;lt; LED1); /* Set pin 7 to output */&lt;BR /&gt;PTC-&amp;gt;PCOR |= (1UL &amp;lt;&amp;lt; LED1); /* Set pin 7 low */&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Any assistance would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; border: 0px; font-weight: inherit; font-size: 14px;"&gt;Paul Swanson&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Jul 2019 01:50:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Problem-with-PIT-triggered-DMA/m-p/914881#M53555</guid>
      <dc:creator>q1220200</dc:creator>
      <dc:date>2019-07-28T01:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with PIT triggered DMA ...</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Problem-with-PIT-triggered-DMA/m-p/914882#M53556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not to worry, I solved it!&lt;/P&gt;&lt;P&gt;(With the help of an excellent book, thank you Alexander Dean&amp;nbsp;&lt;A href="https://www.arm.com/resources/education/books/efficient-embedded-systems" style="color: #2989c5; text-decoration: none;" title="https://www.arm.com/resources/education/books/efficient-embedded-systems"&gt;Textbooks - Efficient Embedded Systems Design and Programming – Arm&lt;/A&gt;&amp;nbsp;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the solution for posterity's sake, how to toggle a GPIO pin using only PIT, DMA &amp;amp; GPIO. The IRQ handlers are necessary but only serve to prepare the prepare the&amp;nbsp;modules for each subsequent event:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define LED1 7&lt;BR /&gt;const uint32_t LED1_DMA = (1UL &amp;lt;&amp;lt; LED1);&lt;BR /&gt;uint32_t foo = 0;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void PIT_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;PIT-&amp;gt;CHANNEL[0].TFLG |= PIT_TFLG_TIF(0);&lt;BR /&gt;}&lt;BR /&gt;void DMA0_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DMA0-&amp;gt;DMA[0].DSR_BCR |= DMA_DSR_BCR_DONE_MASK;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DMA0-&amp;gt;DMA[0].SAR = (uint32_t)&amp;amp;LED1_DMA;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DMA0-&amp;gt;DMA[0].DAR = (uint32_t)&amp;amp;PTC-&amp;gt;PTOR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DMA0-&amp;gt;DMA[0].DSR_BCR = DMA_DSR_BCR_BCR(4);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DMA0-&amp;gt;DMA[0].DSR_BCR &amp;amp;= ~DMA_DSR_BCR_DONE_MASK;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DMAMUX0-&amp;gt;CHCFG[0] |= DMAMUX_CHCFG_ENBL(1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* The following is inside the main() * and implies board initialisation and loop etc */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Configure clock for PORTC, DMA Multiplexer, DMA &amp;amp; PIT&lt;BR /&gt;SIM-&amp;gt;SCGC5 |= SIM_SCGC5_PORTC(1);&lt;BR /&gt;SIM-&amp;gt;SCGC6 |= SIM_SCGC6_DMAMUX(1) | SIM_SCGC6_PIT(1);&lt;BR /&gt;SIM-&amp;gt;SCGC7 |= SIM_SCGC7_DMA(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Set Port C Pin 7 to GPIO module */&lt;BR /&gt;PORTC-&amp;gt;PCR[LED1] &amp;amp;= ~PORT_PCR_MUX_MASK; /* Clear MUX bits */&lt;BR /&gt;PORTC-&amp;gt;PCR[LED1] |= PORT_PCR_MUX(1); /* Enable pin 7 for GPIO */&lt;BR /&gt;PTC-&amp;gt;PDDR |= (1UL &amp;lt;&amp;lt; LED1); /* Set pin 7 to output */&lt;BR /&gt;PTC-&amp;gt;PCOR |= (1UL &amp;lt;&amp;lt; LED1); /* Set pin 7 low */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Disable DMAMUX channel and PIT timer&lt;BR /&gt;DMAMUX0-&amp;gt;CHCFG[0] = 0;&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].TCTRL &amp;amp;= ~PIT_TCTRL_TEN(1);&lt;/P&gt;&lt;P&gt;// Configure DMA Source and Destination addresses&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DCR = DMA_DCR_ERQ(1) | DMA_DCR_CS(1) | DMA_DCR_EINT(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Configure PIT&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].LDVAL = SystemCoreClock - 1; // 47999999 or one second&lt;BR /&gt;PIT-&amp;gt;CHANNEL[0].TCTRL |= PIT_TCTRL_TEN(1) | PIT_TCTRL_TIE(1);&lt;BR /&gt;PIT-&amp;gt;MCR = 0; /* Module enabled, don't freeze in debug */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Enable DMAMUX0 Channel 0, always on and triggered&lt;BR /&gt;DMAMUX0-&amp;gt;CHCFG[0] |= DMAMUX_CHCFG_TRIG(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Set up interrupt controller */&lt;BR /&gt;NVIC_SetPriority(PIT_IRQn, 2);&lt;BR /&gt;NVIC_ClearPendingIRQ(PIT_IRQn);&lt;BR /&gt;NVIC_EnableIRQ(PIT_IRQn);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NVIC_SetPriority(DMA0_IRQn, 0);&lt;BR /&gt;NVIC_ClearPendingIRQ(DMA0_IRQn);&lt;BR /&gt;NVIC_EnableIRQ(DMA0_IRQn);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DMAMUX0-&amp;gt;CHCFG[0] |= DMAMUX_CHCFG_SOURCE(60);&lt;/P&gt;&lt;P&gt;DMA0-&amp;gt;DMA[0].SAR = (uint32_t)&amp;amp;LED1_DMA;&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DAR = (uint32_t)&amp;amp;PTC-&amp;gt;PTOR;&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DSR_BCR = DMA_DSR_BCR_BCR(4);&lt;BR /&gt;DMA0-&amp;gt;DMA[0].DSR_BCR &amp;amp;= ~DMA_DSR_BCR_DONE_MASK;&lt;/P&gt;&lt;P&gt;DMAMUX0-&amp;gt;CHCFG[0] |= DMAMUX_CHCFG_ENBL(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* LED toggles off and on once a second from this point on */&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2019 00:48:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Problem-with-PIT-triggered-DMA/m-p/914882#M53556</guid>
      <dc:creator>q1220200</dc:creator>
      <dc:date>2019-07-29T00:48:58Z</dc:date>
    </item>
  </channel>
</rss>

