<?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 Re: How to write DMA code for new eDMA? in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1183037#M15501</link>
    <description>&lt;P&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Nov 2020 13:44:00 GMT</pubDate>
    <dc:creator>fasihahmed</dc:creator>
    <dc:date>2020-11-18T13:44:00Z</dc:date>
    <item>
      <title>How to write DMA code for new eDMA?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1178684#M15492</link>
      <description>&lt;P&gt;I have a source code for DMA on older mc56f82748 DSC, and now have to port the same feature to new mc56f83763 DSC which use eDMA..&lt;/P&gt;&lt;P&gt;The registers and ioctl calls are named completely different, which makes it hard to re-write the code originally working on legacy source code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help with it?&amp;nbsp; I have attached the legacy source code, and will need some guidance how to write it for the new DSC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void DMA_Init(void)&lt;BR /&gt;{&lt;BR /&gt;ioctl(DMA, DMA_INIT, NULL);&lt;BR /&gt;ioctl(DMA_0, DMA_INIT, NULL);&lt;BR /&gt;ioctl(DMA_0, DMA_SET_PERIPHERAL_REQUEST, DMA_DISABLE); // Disable peripheral request before modifying DMA registers&lt;BR /&gt;&lt;BR /&gt;ioctl(DMA_0, DMA_WRITE_DSR_BCR, 6*2); // 12 bytes on DMA0 (12-bit result register ADC_RA)&lt;BR /&gt;uw32Address = (UWord32)&amp;amp;(w16IphaseArray[0]);&lt;BR /&gt;// set destination address to first member of the structure //&lt;BR /&gt;ioctl(DMA_0, DMA_SET_DESTINATION_ADDRESS, uw32Address&amp;lt;&amp;lt;1);&lt;BR /&gt;ioctl(DMA_0, DMA_SET_SOURCE_ADDRESS, 0x1CA1C);&lt;BR /&gt;// clear interrupt flag and enable next transfer by writing BCR registers&lt;BR /&gt;ioctl(DMA_0, DMA_SET_PERIPHERAL_REQUEST, DMA_ENABLE); // Enable peripheral request to initiate the DMA transfer&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/13026"&gt;@ZhangJennie&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/100097"&gt;@xianduidong&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/26034"&gt;@xiangjun_rong&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 09:49:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1178684#M15492</guid>
      <dc:creator>fasihahmed</dc:creator>
      <dc:date>2020-11-05T09:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to write DMA code for new eDMA?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1179259#M15494</link>
      <description>&lt;P&gt;Hi, Fasih,&lt;/P&gt;
&lt;P&gt;Unfortunately, as you know that the eDMA is the IP which is the same as that of Kinetis K family, and i.mxrt10xx family, so you can refer to Kinetis or i.mxrt for the source code of eDMA.&lt;/P&gt;
&lt;P&gt;This is the source code based on FRDM-K64 I have developed, which can transfer from memory to memory, you can refer to it.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;#include "MK64F12.h"&lt;BR /&gt;#define N 100&lt;BR /&gt;static void DmaInit(void);&lt;BR /&gt;void PollFlag(void);&lt;/P&gt;
&lt;P&gt;uint32_t sArray[N],dArray[N];&lt;BR /&gt;uint32_t i,j,k;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;/* Write your code here */&lt;BR /&gt;for(i=0; i&amp;lt;N; i++)&lt;BR /&gt;{&lt;BR /&gt;sArray[i]=i;&lt;BR /&gt;}&lt;BR /&gt;DmaInit();&lt;BR /&gt;PollFlag();&lt;BR /&gt;/* This for loop should be replaced. By default this loop allows a single stepping. */&lt;BR /&gt;for (;;) {&lt;BR /&gt;j++;&lt;BR /&gt;}&lt;BR /&gt;/* Never leave main */&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;static void DmaInit(void)&lt;BR /&gt;{&lt;BR /&gt;//enable DMA gated clock&lt;BR /&gt;SIM_SCGC7|=0x02;&lt;BR /&gt;SIM_SCGC6|=0x02;&lt;BR /&gt;//set the DMA triggering channel, channel63 is always triggering&lt;BR /&gt;DMAMUX_CHCFG0|=63;&lt;BR /&gt;DMA_CR|=0x80;&lt;BR /&gt;//source address&lt;BR /&gt;DMA_TCD0_SADDR=(uint32_t)&amp;amp;sArray[0];&lt;BR /&gt;//source offset&lt;BR /&gt;DMA_TCD0_SOFF=0x04;&lt;BR /&gt;DMA_TCD0_ATTR=0x0202;&lt;BR /&gt;//minor loop count number&lt;BR /&gt;DMA_TCD0_NBYTES_MLOFFYES=(1&amp;lt;&amp;lt;31)|((4*N)&amp;lt;&amp;lt;10)|(4*N);&lt;BR /&gt;DMA_TCD0_SLAST=0x00;&lt;BR /&gt;DMA_TCD0_DADDR=(uint32_t)&amp;amp;dArray[0];&lt;BR /&gt;DMA_TCD0_DOFF=0x04;&lt;BR /&gt;//major counter&lt;BR /&gt;DMA_TCD0_CITER_ELINKNO=0x01;&lt;BR /&gt;DMA_TCD0_DLASTSGA=0x00;&lt;BR /&gt;DMA_TCD0_BITER_ELINKNO=0x01;&lt;BR /&gt;//enable DMA trigger&lt;BR /&gt;DMAMUX_CHCFG0|=0x80;&lt;BR /&gt;//start DMA&lt;BR /&gt;DMA_TCD0_CSR|=0x01;&lt;BR /&gt;//while(!(DMA_TCD0_CSR&amp;amp;0x80)) {}&lt;BR /&gt;//__asm("nop");&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt;void PollFlag(void)&lt;BR /&gt;{&lt;BR /&gt;while(!(DMA_TCD0_CSR&amp;amp;0x80)) {}&lt;BR /&gt;__asm("nop");&lt;BR /&gt;}&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// EOF&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 08:04:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1179259#M15494</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2020-11-06T08:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to write DMA code for new eDMA?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1180532#M15497</link>
      <description>&lt;P&gt;Hi, Fasih,&lt;/P&gt;
&lt;P&gt;I will try to develop the code, the PIT is used to trigger ADC based on MC56F83000-EVK board, the ADC end of scan event can trigger eDMA.&lt;/P&gt;
&lt;P&gt;maybe I can post the code at the end of this week.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 06:40:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1180532#M15497</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2020-11-10T06:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to write DMA code for new eDMA?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1181333#M15500</link>
      <description>&lt;P&gt;Hi, Fasih,&lt;/P&gt;
&lt;P&gt;I have tried to use the code to test the PIT/ADC/eDMA, it appears it works fine. I develop the code under CW for mcu ver11.x, MC56F83000-EVK. But it is not fully tested.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;#define N 100&lt;BR /&gt;#define CHANNEL_NUMBER_EACH_TRIGGER 4&lt;/P&gt;
&lt;P&gt;void eDMA_ADC_MultipleChannel(void);&lt;/P&gt;
&lt;P&gt;void ADCPit0TriggereMultipleChannelDMA(void);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;uint16_t sample[N];&lt;/P&gt;
&lt;P&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;INTC-&amp;gt;VBA = (uint16_t)(&amp;amp;vba_vector_addr);&lt;BR /&gt;__EI(0); // enable interrupts of all priorities&lt;BR /&gt;LED0_Init();&lt;/P&gt;
&lt;P&gt;configADCPins();&lt;/P&gt;
&lt;P&gt;ADCPit0TriggereMultipleChannelDMA();&lt;BR /&gt;eDMA_ADC_MultipleChannel();&lt;BR /&gt;&lt;BR /&gt;// memTomem_eDMA();&lt;BR /&gt;while(1) {}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//ADC will sample CH0/CH1/CH2/CH3, total 4 channel&lt;BR /&gt;void ADCPit0TriggereMultipleChannelDMA(void)&lt;BR /&gt;{&lt;BR /&gt;//PIT0 init&lt;BR /&gt;SIM-&amp;gt;PCE2|=1&amp;lt;&amp;lt;3;&lt;BR /&gt;//PIT0 prescaler is 32768, the PIT0 cycl;e time is (100 000 000/32768)=3051&lt;BR /&gt;PIT0-&amp;gt;CTRL=0x0F&amp;lt;&amp;lt;3;&lt;BR /&gt;PIT0-&amp;gt;MOD=5;&lt;BR /&gt;//PIT0-&amp;gt;CTRL|=0x01;&lt;BR /&gt;&lt;BR /&gt;//set up crossbar so that the PIT0 can trigger ADC&lt;BR /&gt;//XBAR_OUT12 ADCA_TRIG ADCA (Cyclic ADC) Trigger&lt;BR /&gt;//PIT0_SYNC_OUT PIT0 Sync Output XBAR_IN44&lt;BR /&gt;&lt;BR /&gt;XBARA-&amp;gt;SEL6=44;&lt;BR /&gt;//ADC init&lt;BR /&gt;//enable ADC gated clock &lt;BR /&gt;SIM-&amp;gt;PCE2|=1&amp;lt;&amp;lt;7;&lt;BR /&gt;//init ADC module&lt;BR /&gt;//using hardware to start ADC, enable ADC end of scan interrupt&lt;BR /&gt;//Triggered sequential mode&lt;BR /&gt;ADC-&amp;gt;CTRL1=0x9004;&lt;BR /&gt;//ADC clock is 100MHz/6=16.67MHz&lt;BR /&gt;ADC-&amp;gt;CTRL2=0x02;&lt;BR /&gt;//ADC will sample CH0/CH1/CH2/CH3, total 4 channel&lt;BR /&gt;ADC-&amp;gt;CLIST1=0x3210;&lt;BR /&gt;//sinfgle channel is sampled&lt;BR /&gt;ADC-&amp;gt;SDIS=0xFFF0;&lt;BR /&gt;//configure ADC PWR reg&lt;BR /&gt;ADC-&amp;gt;PWR2=0x200;&lt;BR /&gt;ADC-&amp;gt;PWR=0x304;&lt;BR /&gt;//Poll id the ADC is powered up, the delay time is 0x30 clock cycles&lt;BR /&gt;while(ADC-&amp;gt;PWR&amp;amp;0x400) {}&lt;BR /&gt;&lt;BR /&gt;//set up voltage reference&lt;BR /&gt;ADC-&amp;gt;CAL=0x00;&lt;BR /&gt;i=0;&lt;BR /&gt;//start PIT0&lt;BR /&gt;PIT0-&amp;gt;CTRL|=0x01;&lt;BR /&gt;__asm(NOP);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;void eDMA_ADC_MultipleChannel(void)&lt;BR /&gt;{&lt;BR /&gt;uint32_t temp;&lt;BR /&gt;//set up eDMA channel0 interrupt&lt;BR /&gt;INTC-&amp;gt;IPR3|=0xC0;&lt;BR /&gt;DMA-&amp;gt;INT|=0x01;&lt;BR /&gt;//enable EDMA channel 0 interrupt&lt;BR /&gt;//enable always channel&lt;BR /&gt;&lt;BR /&gt;SIM-&amp;gt;CTRL&amp;amp;=~(0x1C0);&lt;BR /&gt;SIM-&amp;gt;CTRL|=0x1C0;&lt;BR /&gt;//reset DMAMUX&lt;BR /&gt;SIM-&amp;gt;PSWR3|=0x200;&lt;BR /&gt;__asm(NOP);&lt;BR /&gt;__asm(NOP);&lt;BR /&gt;SIM-&amp;gt;PSWR3&amp;amp;=~(0x200);&lt;BR /&gt;//48 ADCA_ES ADCA End of Scan&lt;BR /&gt;DMAMUX-&amp;gt;CHCFG[0]=48; &lt;BR /&gt;//initalize the eDMA module&lt;BR /&gt;//enable minor loop and debug mode&lt;BR /&gt;DMA-&amp;gt;CR|=0x82;&lt;BR /&gt;//word address &amp;amp;ADC-&amp;gt;RSLT[0]=0xE500+E=0xE50E, byte address is 0x1CA1C&lt;BR /&gt;DMA-&amp;gt;TCD[0].SADDR=(uint32_t)&amp;amp;ADC-&amp;gt;RSLT[0]&amp;lt;&amp;lt;1;&lt;BR /&gt;//source offset 2 bytes&lt;BR /&gt;DMA-&amp;gt;TCD[0].SOFF=0x02;&lt;BR /&gt;//two bytes for each transfer &lt;BR /&gt;DMA-&amp;gt;TCD[0].ATTR=0x0101;&lt;BR /&gt;//minor loop count number&lt;BR /&gt;temp=(-2*CHANNEL_NUMBER_EACH_TRIGGER)&amp;lt;&amp;lt;10;&lt;BR /&gt;temp&amp;amp;=0x3FFFFC00;&lt;BR /&gt;temp|=0x80000000;&lt;BR /&gt;temp|=2*CHANNEL_NUMBER_EACH_TRIGGER;&lt;BR /&gt;DMA-&amp;gt;TCD[0].NBYTES_MLOFFYES=temp;&lt;BR /&gt;__asm(nop); //break point, check the DMA-&amp;gt;TCD[0].NBYTES_MLOFFYES reg&lt;BR /&gt;DMA-&amp;gt;TCD[0].SLAST=0x00;&lt;BR /&gt;DMA-&amp;gt;TCD[0].DADDR=(uint32_t)&amp;amp;sample[0]&amp;lt;&amp;lt;1;&lt;BR /&gt;DMA-&amp;gt;TCD[0].DOFF=0x02;&lt;BR /&gt;//major counter&lt;BR /&gt;DMA-&amp;gt;TCD[0].CITER_ELINKNO=N/4;&lt;BR /&gt;DMA-&amp;gt;TCD[0].DLASTSGA=0x00;&lt;BR /&gt;DMA-&amp;gt;TCD[0].BITER_ELINKNO=N/4;&lt;BR /&gt;//enable DMA trigger&lt;BR /&gt;DMAMUX-&amp;gt;CHCFG[0]|=0x80;&lt;BR /&gt;//DMA-&amp;gt;ERQ|=0x01;&lt;BR /&gt;//enable eDMA channel 0 interrupt&lt;BR /&gt;DMA-&amp;gt;TCD[0].CSR|=0x02;&lt;BR /&gt;DMA-&amp;gt;ERQ=0x01;&lt;BR /&gt;//start DMA for software trigger&lt;BR /&gt;//DMA-&amp;gt;TCD[0].CSR|=0x01;&lt;BR /&gt;// while(!(DMA-&amp;gt;TCD[0].CSR&amp;amp;0x80)) {}&lt;BR /&gt;__asm(nop);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//GPIOA0/A1/A2/A3 become ANA0/ANA1/ANA2/ANA3&lt;BR /&gt;void configADCPins(void)&lt;BR /&gt;{&lt;BR /&gt;//enable GPIOA gated clock&lt;BR /&gt;SIM-&amp;gt;PCE0|=0x40;&lt;BR /&gt;GPIOA-&amp;gt;PER|=0x0F;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;#pragma interrupt on&lt;BR /&gt;void eDMA_0_ISR(void)&lt;BR /&gt;{&lt;BR /&gt;//clear DONE flag of eDMA channel 0&lt;BR /&gt;// DMA-&amp;gt;TCD[0].BITER_ELINKNO=N/4;&lt;BR /&gt;// DMA-&amp;gt;TCD[0].CITER_ELINKNO=N/4;&lt;BR /&gt;DMA-&amp;gt;CDNE=0x40;&lt;BR /&gt;//clear DONE bit&lt;BR /&gt;DMA-&amp;gt;TCD[0].CSR|=0x80;&lt;BR /&gt;PIT0-&amp;gt;CTRL&amp;amp;=~(0x01);&lt;BR /&gt;__asm(NOP);&lt;BR /&gt;}&lt;BR /&gt;#pragma interrupt off&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in the MC56F83xxx_Vectors.c&lt;/P&gt;
&lt;P&gt;extern void eDMA_0_ISR(void);&lt;/P&gt;
&lt;P&gt;volatile asm void _vect(void) {&lt;BR /&gt;JMP &amp;gt;_EntryPoint /* Interrupt no. 0 (Used)*/&lt;BR /&gt;JMP &amp;gt;_EntryPoint /* Interrupt no. 1 (Used)*/&lt;BR /&gt;JSR &amp;gt;ivINT_ILLEGAL_OP /* Interrupt no. 2*/&lt;BR /&gt;JSR &amp;gt;ivINT_SWI3 /* Interrupt no. 3*/&lt;BR /&gt;JSR &amp;gt;ivINT_OVERFLOW /* Interrupt no. 4*/&lt;BR /&gt;JSR &amp;gt;ivINT_MISALIGNED /* Interrupt no. 5*/&lt;BR /&gt;JSR &amp;gt;ivINT_STPCNT /* Interrupt no. 6*/&lt;BR /&gt;JSR &amp;gt;ivINT_BKPT /* Interrupt no. 7*/&lt;BR /&gt;JSR &amp;gt;ivINT_TRBUF /* Interrupt no. 8*/&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;JSR &amp;gt;eDMA_0_ISR //ivINT_DMA0 /* Interrupt no. 36*/&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 08:15:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1181333#M15500</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2020-11-11T08:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to write DMA code for new eDMA?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1183037#M15501</link>
      <description>&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 13:44:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-write-DMA-code-for-new-eDMA/m-p/1183037#M15501</guid>
      <dc:creator>fasihahmed</dc:creator>
      <dc:date>2020-11-18T13:44:00Z</dc:date>
    </item>
  </channel>
</rss>

