打印
[PIC®/AVR®/dsPIC®产品]

PIC18F的DMA的练习与问题

[复制链接]
265|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
配置如下

#include "mcc_generated_files/system/system.h"

/*
    Main application
*/
int i=0;

int main(void)
{
    SYSTEM_Initialize();

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

    // Enable the Global Interrupts
    //INTERRUPT_GlobalInterruptEnable();

    // Disable the Global Interrupts
    //INTERRUPT_GlobalInterruptDisable();
    printf("Hello \n");
    for(int i=0;i<10;i++)
    {
        SrcVarName1[i]='1'+i;
    }
    for(int i=0;i<10;i++)
    {
        putch(SrcVarName1[i]);
    }
    putch('\n');

    while(1)
    {
        __delay_ms(1000);
        
        i++;
        if(i>20)
        {
            DMA1_StopTransfer();
        }
        else
        {
            DMA1_StartTransfer();
        }
        if(i>30) i=0;
    }   
}
这个软件触发是没问题的,很奈斯,参靠的版主的帖子。

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


比如应该收到如下内容
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 | 只看该作者
完犊子,实在解决不了。找了一个迂回的方式,放中断里软件触发。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

202

主题

3490

帖子

10

粉丝