DSP

Blackfin BF537 的 DMA模式 UART通信程序简例

2019-07-13 16:51发布

 http://blog.sina.com.cn/s/blog_61e8ebaa0100eq28.html 2009年09月01日, Blackfin系列DSP学习,第一例: 以DMA模式接收一组数据,显示接收成功。 磊正shuleizh@126.com #include "GPSData.h"
#include "uart.h"
#define SSYNC    asm("ssync;")
#define X_COUNT  3   volatile char sUART0_RxBuffer[X_COUNT];
/
void config_dma9(void) //Uart0 TX
{
 *pDMA9_CONFIG=0;  *pDMA9_CONFIG |=FLOW_AUTO+NDSIZE_0+DI_EN+0x0020+WDSIZE_8+WNR;
             // AutoBuffer +Interrupt when completion +SYNC +8 bit transfer+memory write
 SSYNC;

*pDMA9_START_ADDR=0xFFC00E44; 
 SSYNC;
 
 *pDMA9_X_COUNT=X_COUNT; 
 SSYNC;
 
 *pDMA9_X_MODIFY=1;
 SSYNC;
 
 *pDMA9_CONFIG |=DMAEN; 
}

void config_dma8(void) //Uart0 RX
{
 *pDMA8_CONFIG=0;
 *pDMA8_CONFIG |=FLOW_AUTO+NDSIZE_0+0x0020+WDSIZE_8+WNR+DI_EN;
             // AutoBuffer +1D,Interrupt when completion +SYNC +8 bit transfer+memory write
 SSYNC;
 
 *pDMA8_START_ADDR=(void *)sUART0_RxBuffer;
 SSYNC;
 
 *pDMA8_X_COUNT=X_COUNT;
 SSYNC;
 
 *pDMA8_X_MODIFY=1;
 SSYNC;
 
 *pDMA8_CONFIG |=DMAEN; 
}
//**************************************************************************** void Config_Uart0_Interrupt(void)
{
    config_dma8();     //Uart0 RX-> DMA mode
    init_uart0_dma();
 
    //assign core IDs to interrupt
   *pSIC_IAR0 = 0xffffffff;
   *pSIC_IAR1 = 0xfff33fff; //DMA8/9 (UART0 TX/RX)-->IVG10
   *pSIC_IAR2 = 0xffffffff; 
   *pSIC_IAR3 = 0xffffffff; 
   
 //assign ISRs to interrupt vectors
 register_handler(ik_ivg10,UART0_ISR); // IVG10-> UART0_ISR
 
 //enable interrupt
    //*pSIC_IMASK=IRQ_DMA8+IRQ_DMA9; // enable UART0_TX and UART0_RX
    *pSIC_IMASK=IRQ_DMA8; // enable UART0_RX interrupt, used when command a function
}
//****************************************************************************
//UARTx Interrupt Service Function
EX_INTERRUPT_HANDLER(UART0_ISR)
{
 
        // rcv_buf[0]=*pUART0_RBR;
         *pDMA8_IRQ_STATUS |=1;
         uart0SendString("DMA Recieved a message!"); 
        // uart0SendChar(rcv_buf[0]);
         uart0SendString(" ");
        
   
}