完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
|
大家好,我为PIC32 MZ2048 EFG100配置了DMA。我已经测试了芯片上的代码和MPLABX模拟器。我只能看到通过DMA通道“0”传送的数据的一半。我不知道我的配置哪里错了。代码片段附在下面。由于某种原因,我不想使用和声。任何建议/想法都会被赏识的。谢谢。
以上来自于百度翻译 以下为原文 Hello All, I have configured DMA for PIC32MZ2048EFG100. I have tested the code on chip and in MPLABX simulator as well. I can see only transfer half of the data transfered by DMA channel '0'. I don't know where my configuration is wrong. Code snippet is attached below. For some reason I don't want to use HARMony. Any suggestion/ideas will be appreciated. Thanks in advance /* * File: main.c * * Created on April 24, 2017, 9:18 PM */ #include #include #include #include #include "config.h" /* tested config bits*/ #define KVA_TO_PA(v) ((unsigned long)(v) & 0x1FFFFFFF) volatile short __attribute__((coherent)) data[10] = {0,1,2,3,4,0,1,2,3,4}; volatile short data2[10] = {0,0,0,0,0,0,0,0,0,0}; void DMA_Init(void); int main(int argc, char** argv) { // Pre-fetch-cache: Enable pre-fetch for PFM (any PFM instructions or data) PRECONbits.PREFEN = 3; // Flash PM Wait States: MZ Flash runs at 2 wait states @ 200 MHz PRECONbits.PFMWS = 2; // /* Assign PIC32MZ shadow register sets to specific CPU IPLs */ PRISS = 0x76543210; // /* Set Interrupt Controller for multi-vector mode */ INTCONSET = _INTCON_MVEC_MASK; TRISBbits.TRISB4 = 0; // LED as output LATBbits.LATB4 = 1; // Clear to turn on DMA_Init(); __builtin_enable_interrupts(); while (1) { while (DMACONbits.DMABUSY); LATBbits.LATB4 = 0; // Clear to turn on while (1); // debug purpose only -- remove later } // check the transfer completion result return (EXIT_SUCCESS); } void DMA_Init(void){ IEC4bits.DMA0IE = 0; // disable DMA channel 0 interrupts IFS4bits.DMA0IF = 0; // clear any existing DMA channel 0 interrupt flag DMACONbits.ON = 1; // enable the DMA controller DCH0CON = 0x03; // channel off, priority 3, no chaining DCH0ECON = 0; //DCH0SSA = (int) &(SPIxBUF); // source address DCH0SSA = KVA_TO_PA(&data); DCH0DSA = KVA_TO_PA(&data2); // destination address DCH0SSIZ = 10; // source size DCH0DSIZ = 10; // destination size DCH0CSIZ = 10; // no of bytes transferred per event DCH0INT = 0; DCH0INTCLR=0x00ff00ff; DCH0INTbits.CHCCIE = 1; IPC33bits.DMA0IP = 0; // clear the DMA channel 0 priority and sub-priority IPC33bits.DMA0IS = 0; IPC33bits.DMA0IP = 5; // set IPL 5, sub-priority 2 IPC33bits.DMA0IS = 2; IEC4bits.DMA0IE = 1; // enable DMA channel 0 interrupt DCH0CONbits.CHEN = 1; // turn channel on DCH0ECONbits.CFORCE = 1 ; while(DCH0CONbits.CHBUSY){} } void __ISR_AT_VECTOR(_DMA0_VECTOR , IPL5SRS) __DMA0Interrupt(void) { // just to know what is the cause of interrupt if(DCH0INTbits.CHERIF ) __NOP(); // waste a cycle if (DCH0INTbits.CHTAIF ) __NOP(); // waste a cycle if (DCH0INTbits.CHCCIF ) __NOP(); // waste a cycle if (DCH0INTbits.CHBCIF ) __NOP(); // waste a cycle if (DCH0INTbits.CHDHIF ) __NOP(); // waste a cycle if (DCH0INTbits.CHDDIF ) __NOP(); // waste a cycle if (DCH0INTbits.CHSHIF ) __NOP(); // waste a cycle if (DCH0INTbits.CHSDIF ) __NOP(); // waste a cycle DCH0INTCLR = 0x000000ff; IFS4bits.DMA0IF = 0; // clear any existing DMA channel 0 interrupt flag } |
|
相关推荐
4个回答
|
|
|
嗨,我认为用模拟器测试DMA的任何东西都是非常危险的,特别是在32位上,因为各种内部总线之间的复杂交互作用。使用起动器套件更有意义。奇基威火?当做
以上来自于百度翻译 以下为原文 Hi, To my opinion it is very risky to test anything which has to see with DMA with the simulator, especially on 32 bits because of the complex interactions between the various internal busses. It makes much more sense to use a starter kit. ChipkitWi-Fire ? Regards |
|
|
|
|
|
嗨,RISC。我在大学的一个定制板上测试了上面的代码。使用ICD和模拟器的结果是相同的。
以上来自于百度翻译 以下为原文 Hi, @ RISC. I tested the above code on a custom made board at the university. The result from using ICD and simulator are the same. |
|
|
|
|
|
你的内存数组被声明为短路,所以你声明的每个“数字”都填充了两个字节,所以它们实际上是20字节长。或者传输20字节,或者将数据数组更改为8位元素。
以上来自于百度翻译 以下为原文 You have your memory arrays declared as shorts, so each "number" you have declared fills up two bytes, so they are in fact 20 bytes long. Either transfer 20 bytes, or change your data arrays to 8 bit elements. |
|
|
|
|
|
嗨,谢谢你。我已经明白了这一点。我做了这个改变,这是有意义的,因为DMA不知道我声明的数据类型。不管怎样,谢谢你的回答。
以上来自于百度翻译 以下为原文 Hi, Thanks @jg_ee. I already have figured this out. I made this change. DCH0SSIZ = 10 * sizeof (short) ; // source size DCH0DSIZ = 10 * sizeof (short) ; // destination size DCH0CSIZ = 10 * sizeof (short) ; // no of bytes transferred per eventAn this makes sense since DMA does not know about the data type I declared. Anyway thanks for reply. Cheers |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5795 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1125浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-3 02:57 , Processed in 0.717808 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1425