打印

PIC33里大家有没有使用多个DMA通道的情况

[复制链接]
4866|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
charlen|  楼主 | 2009-10-14 14:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
小弟最近在用PIC33做一个项目,有模拟量采集,输入捕捉,还有串口通信,同时还用到多个定时器。为了减轻CPU负担,模拟量采集使用了DMA0通道,输入捕捉使用了DMA1通道,现在想两个串口也使用DMA通道,但发现PIC33里中断处理函数里没有DMA2,3,4,5,6的中断处理函数,比如如果有类似通道DMA0的中断函数声明如下:
void __attribute__((interrupt, no_auto_psv)) __DMA4Interrupt(void);
void __attribute__((interrupt, no_auto_psv)) __DMA5Interrupt(void);

void __attribute__((interrupt, no_auto_psv)) __DMA2Interrupt(void);
void __attribute__((interrupt, no_auto_psv)) __DMA3Interrupt(void);

然后在定义这几个函数的
编译器就报如下错误:
src\UART.C:716: warning: Invalid interrupt vector names for device '33FJ128MC706' are:
__DMA4Interrupt
__DMA5Interrupt
__DMA2Interrupt
__DMA3Interrupt
__DMA4Interrupt
__DMA2Interrupt
__DMA5Interrupt
__DMA3Interrupt


我看中断向量表里有这些中断源处理的地址,如
AVIT地址             中断源
0x00011c            DMA0
0x000130            DMA1
0x000144            DMA2
0x00015c            DMA3
.......
0x00019c            DMA6
0x00018e            DMA7
但我发现Program Memory里没有这些函数,只有DMA0,DMA1,DMA7,其他DMA的中断函数都用_DefaultInterrupt代替,请问要是我想用DAM2,3,4,5来处理,该怎么做呢??
沙发
charlen|  楼主 | 2009-10-14 15:56 | 只看该作者
把目前调试出现的问题再说一下,我看了gld文件后,把中断函数名改为:
void __attribute__((__interrupt__)) _DMA4Interrupt(void);       
void __attribute__((__interrupt__)) _DMA5Interrupt(void);       
void __attribute__((__interrupt__)) _DMA2Interrupt(void);
void __attribute__((__interrupt__)) _DMA3Interrupt(void);

这样之后,编译器可以通过,但好像DMA中断进不去,就是接收数据的DMA中断进不去,用UART2,初始化是这样的:
void InitUart2(void)
{  
        Uint16 Baud;
        U2MODE = 0 ;
        U2STA = 0 ;               
        U2MODEbits.STSEL = 0;                //  1-stop bit
        U2MODEbits.PDSEL = 0;                //  No Parity,8-data bits
        U2MODEbits.ABAUD = 0;                //Auto-Baud Disabled
               
        Baud = Fuc_Vars.fixedVarname.combaud2;
        if(Baud > 3) Baud = 2;                                        //9600
        U2BRG = Tab_Baud[Baud];                                        // 260 ;        // Baud-Rate-Rate = 9600 when Fcy = 40M , BRGH = 1

        //Ctrl_U2RX = INPUT ;
        //Ctrl_U2TX = OUTPUT ;

        U2STAbits.UTXISEL0 = 0;        //Interrupt after one TX character is transmitted         
        U2STAbits.UTXISEL1 = 0;
        U2STAbits.URXISEL = 0;        //Interrupt after one RX character is received

        U2MODEbits.UARTEN = 1;                // Enable UART
        U2STAbits.UTXEN = 1;                //Enable UART Tx
       
        IEC4bits.U2EIE = 0;
        //Set up DMA Channel 2 to Transmit in One-Shot,Single-Buffer Mode:
        DMA2REQ = 0x001F;                //Select UART2 Transmitter
        DMA2PAD = (volatile unsigned int)&U2TXREG;
        //DMA2CON = 0x2001;               
        DMA2CONbits.AMODE = 0;
        DMA2CONbits.MODE  = 1;
        DMA2CONbits.DIR   = 1;
        DMA2CONbits.SIZE  = 0;
       
        DMA2CNT = 255;                        //8 DMA request
        DMA2STA = __builtin_dmaoffset(BufferF);
       
        IFS1bits.DMA2IF = 0;        //Clear DMA Interrupt Flag
        IEC1bits.DMA2IE = 1;                //Enable DMA interrupt
       
               

        //Set up DMA Channel 3 to Receive in Continuous Ping-Pong Mode:
        DMA3REQ = 0x001E;                //Select UART2 Receiver
        DMA3PAD = (volatile unsigned int)&U2RXREG;
        //DMA3CON = 0x0002;       
        DMA1CONbits.AMODE = 0;
        DMA1CONbits.MODE  = 2;
        DMA1CONbits.DIR   = 0;
        DMA1CONbits.SIZE  = 0;
        DMA3CNT = 255;                        //8 DMA requests
               
        DMA3STA = __builtin_dmaoffset(BufferF);
        DMA3STB = __builtin_dmaoffset(BufferG);

        IFS2bits.DMA3IF = 0;
        IEC2bits.DMA3IE = 1;
        DMA3CONbits.CHEN = 1;        // Enable DMA Channel
}

另外开辟的缓冲区是这样:
unsigned char BufferF[256] __attribute__((space(dma)));               
unsigned char BufferG[256] __attribute__((space(dma)));
各位看看是否正确?

使用特权

评论回复
板凳
liul83| | 2009-10-21 10:48 | 只看该作者
lz留下QQ吧 小弟也在用PIC33 项目可能比你的简单 但是比较繁琐 咱们可以讨论讨论

使用特权

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

本版积分规则

7

主题

34

帖子

0

粉丝