[PIC®/AVR®/dsPIC®产品] PIC18F的DMA的练习与问题

[复制链接]
602|3
 楼主| yiyigirl2014 发表于 2023-9-26 12:54 | 显示全部楼层 |阅读模式
配置如下

  1. #include "mcc_generated_files/system/system.h"

  2. /*
  3.     Main application
  4. */
  5. int i=0;

  6. int main(void)
  7. {
  8.     SYSTEM_Initialize();

  9.     // If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
  10.     // If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global Interrupts
  11.     // Use the following macros to:

  12.     // Enable the Global Interrupts
  13.     //INTERRUPT_GlobalInterruptEnable();

  14.     // Disable the Global Interrupts
  15.     //INTERRUPT_GlobalInterruptDisable();
  16.     printf("Hello \n");
  17.     for(int i=0;i<10;i++)
  18.     {
  19.         SrcVarName1[i]='1'+i;
  20.     }
  21.     for(int i=0;i<10;i++)
  22.     {
  23.         putch(SrcVarName1[i]);
  24.     }
  25.     putch('\n');

  26.     while(1)
  27.     {
  28.         __delay_ms(1000);
  29.         
  30.         i++;
  31.         if(i>20)
  32.         {
  33.             DMA1_StopTransfer();
  34.         }
  35.         else
  36.         {
  37.             DMA1_StartTransfer();
  38.         }
  39.         if(i>30) i=0;
  40.     }   
  41. }
这个软件触发是没问题的,很奈斯,参靠的版主的帖子。

也试了他的定时器触发也没问题,很棒。
我改成按键触发后出问题了。配置如下


比如应该收到如下内容
123456789:
实际按一下收到了两个,丢了第三个,搞不懂啊。
124578:134

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| yiyigirl2014 发表于 2023-9-26 12:56 | 显示全部楼层
124578:134679:235689124578:134679:235689124578:134679:
都是这样的,不知道怎么解决了,其他的触发都是没问题的,为何改成了按键中断触发就这样了呢?
 楼主| yiyigirl2014 发表于 2023-9-26 14:51 | 显示全部楼层
突然发现有升级,更新后发现DMA的部分变了,好多生成的代码修改了。。。不过我这个问题还没搞定。
 楼主| yiyigirl2014 发表于 2023-9-26 16:05 | 显示全部楼层
完犊子,实在解决不了。找了一个迂回的方式,放中断里软件触发。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

230

主题

3676

帖子

10

粉丝
快速回复 在线客服 返回列表 返回顶部