<?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>Kinetis Microcontrollers中的主题 Re: Can PIT trigger DMA?</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966634#M55147</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The PIT triggers DMA each time it overflows - there is nothing to configure in the PIT to do this apart from setting it to a periodic operating mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to enable PIT interrupt and you don't need to handle a PIT interrupt (this would be counter productive if it were the case).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the uTasker PIT driver the DMA port case is simply a set up for periodic mode with out interrupt, plus the following lines of code (which add the DMA setup and starts it):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;        if ((PIT_settings-&amp;gt;mode &amp;amp; PIT_OUTPUT_DMA_TRIG) != 0) {           // if the PIT is to trigger a port toggle by DMA
            // Note that PIT channel number must match with the DMA channel (hardware requirement) and the DMA channel is chosen here to match the PIT
            //
            static unsigned long ulPortBits[_PITS_AVAILABLE] = {0};
            ulPortBits[PIT_settings-&amp;gt;ucPIT] = PIT_settings-&amp;gt;ulPortBits;  // the port bit(s) to be toggled
            fnConfigDMA_buffer(PIT_settings-&amp;gt;ucPIT, (DMAMUX0_DMA0_CHCFG_SOURCE_PIT0 + PIT_settings-&amp;gt;ucPIT), sizeof(ulPortBits[PIT_settings-&amp;gt;ucPIT]), &amp;amp;ulPortBits[PIT_settings-&amp;gt;ucPIT], (unsigned long *)(GPIO_BLOCK + (0x040 * PIT_settings-&amp;gt;ucPortRef) + 0x00c), (DMA_DIRECTION_OUTPUT | DMA_LONG_WORDS | DMA_FIXED_ADDRESSES | DMA_NO_MODULO), 0, 0); // source is the port bit and destination is the GPIO toggle register (DMA_FIXED_ADDRESSES and DMA_NO_MODULO are used only by KL parts)
            fnDMA_BufferReset(PIT_settings-&amp;gt;ucPIT, DMA_BUFFER_START);
        }
‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Jul 2019 16:32:34 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2019-07-29T16:32:34Z</dc:date>
    <item>
      <title>Can PIT trigger DMA?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966628#M55141</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&gt;I'm a little confused about how PIT events and DMA relate, on the FRDM-KL25&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'm looking to achieve is this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideally, on the expiration of a PIT timer I want to asynchronously do two things:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;Transfer a single value from a given memory location to a given register&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;Transfer a fixed array of two byte values through to DAC (play a tiny 12bit audio sample)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I'm not completely sure if this is possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, reading the application note "Application of Asynchronous DMA operation" (for the KL25), it&amp;nbsp;lists&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in section 3.2 the modules that are capable of generating DMA requests, PIT is not among them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, referring to pages 87-8 of the "KL25 Sub Family Reference Manual" it specifies that "... PIT generates periodic trigger events to the DMA channel mux ...".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, can I or can't I use PIT events to initiate a DMA transfer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working mostly just with CMSIS and occasionally some Freescale libraries on this project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul Swanson#&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jul 2019 05:22:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966628#M55141</guid>
      <dc:creator>q1220200</dc:creator>
      <dc:date>2019-07-25T05:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can PIT trigger DMA?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966629#M55142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PITs can trigger DMA, with the following restrictions/differences:&lt;BR /&gt;1. PIT0 can only trigger DMA channel 0, PIT1 can only trigger DMA channe 1, etc.&lt;BR /&gt;2. Its trigger source needs to be set to the "always enabled" DMA MUX channel and its channel trigger enabled&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From a programming point of view to use PIT0 you must use DMA channel 0 and set the DMA MUX to (eg. for KL25) to 58 (0x3a) plus 0x40 (enable channel trigger) and enable the DMA mode in the PIT.&lt;BR /&gt;To make this more or less transparent, define the PIT0 trigger source as (58 | 0x40) and then standard DMA configuration can be used without needing to consider the special difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Complete Kinetis solutions for professional needs, training and support: &lt;A href="http://www.utasker.com/kinetis.html" target="test_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Kinetis KL25, KL26, KL27, KL28, KL43, KL46, KL82&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://http://www.utasker.com/kinetis/FRDM-KL25Z.html" target="test_blank"&gt;http://http://www.utasker.com/kinetis/FRDM-KL25Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TWR-KL25Z48M.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TWR-KL25Z48M.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL26Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL26Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TEENSY_LC.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TEENSY_LC.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL27Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL27Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/Capuccino-KL27.html" target="test_blank"&gt;http://www.utasker.com/kinetis/Capuccino-KL27.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL28Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL28Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL43Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL43Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TWR-KL43Z48M.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TWR-KL43Z48M.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL46Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL46Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TWR-KL46Z48M.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TWR-KL46Z48M.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL82Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL82Z.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&lt;EM&gt;uTasker: supporting &amp;gt;1'000 registered Kinetis users get products faster and cheaper to market&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;EM&gt;Request Free emergency remote desk-top consulting at &lt;A href="http://www.utasker.com/services.html" target="test_blank"&gt;http://www.utasker.com/services.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Open Source version at &lt;A href="https://github.com/uTasker/uTasker-Kinetis" target="test_blank"&gt;https://github.com/uTasker/uTasker-Kinetis&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jul 2019 07:52:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966629#M55142</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-07-25T07:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can PIT trigger DMA?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966630#M55143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A couple of follow up questions, because I'm still not having any luck getting this working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, I should have specified the MCU more precisely, it's the&amp;nbsp;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;MKL25Z128VLK4.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;Secondly, what I'm wanting to achieve right now is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;PIT Timer triggers a single (32bit) DMA memory to memory transfer&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;That transfer causes the toggling of a GPIO pin&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;The goal here is to effectively achieve a periodic toggling of a GPIO pin with interrupting the main loop or requiring an interrupt handler to be called.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; 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&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;Here's a sample of the source code (just using CMSIS and some boilerplate code from Freescale):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 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="padding-left: 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="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 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="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 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="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 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;BR /&gt; &lt;BR /&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="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 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&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; 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&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;Any further thoughts would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; font-size: 14px;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #252526; background-color: #ffffff; 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:42:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966630#M55143</guid>
      <dc:creator>q1220200</dc:creator>
      <dc:date>2019-07-28T01:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can PIT trigger DMA?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966631#M55144</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 class="" href="https://www.arm.com/resources/education/books/efficient-embedded-systems" 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:&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;BR /&gt; &lt;BR /&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:45:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966631#M55144</guid>
      <dc:creator>q1220200</dc:creator>
      <dc:date>2019-07-29T00:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can PIT trigger DMA?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966632#M55145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to enable a PIT interrupt since DMA does it all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how it is done in the uTasker project (generating a 500kHz complimentary square wave on PTA0 and PTA1 using PIT1) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;void fnGeneratePIT_square_wave(void)
{
    PIT_SETUP pit_setup;                                                 // PIT interrupt configuration parameters
    pit_setup.int_type = PIT_INTERRUPT;
    _CONFIG_DRIVE_PORT_OUTPUT_VALUE(A, (PORTA_BIT0 | PORTA_BIT1), (PORTA_BIT1), (PORT_SRE_SLOW | PORT_DSE_HIGH)); // set initial port states
    pit_setup.ucPortRef = PORTA;
    pit_setup.ulPortBits = (PORTA_BIT0 | PORTA_BIT1);                    // toggle PTA0/1 on each PIT trigger
    pit_setup.ucPIT = 1;                                                 // use PIT1 (this will use DMA channel 1, 0 would use DMA channel 0, etc.)
    pit_setup.count_delay = PIT_US_DELAY(1);                             // 1us period (for 500kHz square wave)
    pit_setup.mode = (PIT_PERIODIC | PIT_OUTPUT_DMA_TRIG);               // periodic with DMA trigger to control a port toggle
    fnConfigureInterrupt((void *)&amp;amp;pit_setup);                            // configure PIT
}
‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The PIT method has a DMA port output capability built into it. In the lower layers it will look similar to what you have done for the KL25 but will also work on Kinetis parts with eDMA or LPIT so the user doesn't need to worry about the details. &lt;EM&gt;You will need to redevelop the same if you move to a part with eDMA&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2019 04:01:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966632#M55145</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-07-29T04:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can PIT trigger DMA?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966633#M55146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's interesting. Perhaps you can help me better understand your terminology.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On this MCU, I can see that PIT is able to (or does) trigger the first two DMA channels. However, I can not see any documentation in the Sub Family manual or other the suggests the PIT module itself contains any configurable options directly related to DMA; rather the DMAMUX / DMA modules can accept a trigger from the PIT if so configured.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you say "the PIT method has a DMA port output capability built into it", is this ultimately what you're referring to (in the context of uTasker)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, back to your first statement, is it not necessary to clear the PIT interrupt flag with an ISR for proper operation of the PIT?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks as always,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul Swanson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2019 04:12:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966633#M55146</guid>
      <dc:creator>q1220200</dc:creator>
      <dc:date>2019-07-29T04:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can PIT trigger DMA?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966634#M55147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The PIT triggers DMA each time it overflows - there is nothing to configure in the PIT to do this apart from setting it to a periodic operating mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to enable PIT interrupt and you don't need to handle a PIT interrupt (this would be counter productive if it were the case).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the uTasker PIT driver the DMA port case is simply a set up for periodic mode with out interrupt, plus the following lines of code (which add the DMA setup and starts it):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;        if ((PIT_settings-&amp;gt;mode &amp;amp; PIT_OUTPUT_DMA_TRIG) != 0) {           // if the PIT is to trigger a port toggle by DMA
            // Note that PIT channel number must match with the DMA channel (hardware requirement) and the DMA channel is chosen here to match the PIT
            //
            static unsigned long ulPortBits[_PITS_AVAILABLE] = {0};
            ulPortBits[PIT_settings-&amp;gt;ucPIT] = PIT_settings-&amp;gt;ulPortBits;  // the port bit(s) to be toggled
            fnConfigDMA_buffer(PIT_settings-&amp;gt;ucPIT, (DMAMUX0_DMA0_CHCFG_SOURCE_PIT0 + PIT_settings-&amp;gt;ucPIT), sizeof(ulPortBits[PIT_settings-&amp;gt;ucPIT]), &amp;amp;ulPortBits[PIT_settings-&amp;gt;ucPIT], (unsigned long *)(GPIO_BLOCK + (0x040 * PIT_settings-&amp;gt;ucPortRef) + 0x00c), (DMA_DIRECTION_OUTPUT | DMA_LONG_WORDS | DMA_FIXED_ADDRESSES | DMA_NO_MODULO), 0, 0); // source is the port bit and destination is the GPIO toggle register (DMA_FIXED_ADDRESSES and DMA_NO_MODULO are used only by KL parts)
            fnDMA_BufferReset(PIT_settings-&amp;gt;ucPIT, DMA_BUFFER_START);
        }
‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2019 16:32:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Can-PIT-trigger-DMA/m-p/966634#M55147</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-07-29T16:32:34Z</dc:date>
    </item>
  </channel>
</rss>

