⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recfifo.c

📁 dsp vc5509 的多通道SPI通信程序
💻 C
字号:
#include <stdio.h>
#include "registers.h"
#include <csl.h>
#include <csl_irq.h>
#include <csl_dma.h>
//#include "init_dsp.h"
#define N       2048

//---------Global data definition---------
/* Place src and dst of DMA transfer in seperate memory section */
/* to better control placement in user specified memory range   */

DMA_Handle myhDma;
DMA_Config  myconfig = { 
  DMA_DMACSDP_RMK(
    DMA_DMACSDP_DSTBEN_NOBURST,
    DMA_DMACSDP_DSTPACK_OFF,
    DMA_DMACSDP_DST_DARAM,
    DMA_DMACSDP_SRCBEN_NOBURST,
    DMA_DMACSDP_SRCPACK_OFF,
    DMA_DMACSDP_SRC_EMIF,
    DMA_DMACSDP_DATATYPE_32BIT
  ),                                       /* DMACSDP  */
  DMA_DMACCR_RMK(
    DMA_DMACCR_DSTAMODE_POSTINC,
    DMA_DMACCR_SRCAMODE_POSTINC,
    DMA_DMACCR_ENDPROG_ON,
    DMA_DMACCR_REPEAT_OFF,
    DMA_DMACCR_AUTOINIT_ON,
    DMA_DMACCR_EN_STOP,
    DMA_DMACCR_PRIO_HI,
    DMA_DMACCR_FS_DISABLE,
    DMA_DMACCR_SYNC_NONE
  ),                                       /* DMACCR   */
  DMA_DMACICR_RMK(
    DMA_DMACICR_BLOCKIE_OFF,
    DMA_DMACICR_LASTIE_OFF,
    DMA_DMACICR_FRAMEIE_ON,
    DMA_DMACICR_FIRSTHALFIE_OFF,
    DMA_DMACICR_DROPIE_OFF,
    DMA_DMACICR_TIMEOUTIE_OFF
  ),                                       /* DMACICR  */
    (DMA_AdrPtr)DMA_src,                     /* DMACSSAL */
    0,                                     /* DMACSSAU */
    (DMA_AdrPtr)DMA_dst,                     /* DMACDSAL */
    0,                                     /* DMACDSAU */
    2048,                                     /* DMACEN   */
    1,                                     /* DMACFN   */
    0,                                     /* DMACFI   */
    0                                      /* DMACEI   */
};

int i, j;

void taskFxn(void)
{ 
 Uint16 src1AddrHi, src1AddrLo;
//    Uint16 src2AddrHi, src2AddrLo;
    Uint16 dst1AddrHi, dst1AddrLo;
//    Uint16 dst2AddrHi, dst2AddrLo;
//    Uint32 eventId;
//    Uint16 old_intm;

    /* Open DMA Channel 1 setting registers to their power on defualts */
    myhDma = DMA_open(DMA_CHA0, DMA_OPEN_RESET);    


    /* By default, the TMS320C55xx compiler assigns all data symbols word */
    /* addresses. The DMA however, expects all addresses to be byte       */
    /* addresses. Therefore, we must shift the address by 2 in order to   */
    /* change the word address to a byte address for the DMA transfer.    */ 
    src1AddrHi = (Uint16)(((Uint32)(DMA_src)) >> 15) & 0xFFFFu;
    src1AddrLo = (Uint16)(((Uint32)(DMA_src)) << 1) & 0xFFFFu;
    dst1AddrHi = (Uint16)(((Uint32)(DMA_dst)) >> 15) & 0xFFFFu;
    dst1AddrLo = (Uint16)(((Uint32)(DMA_dst)) << 1) & 0xFFFFu;



    myconfig.dmacssal = (DMA_AdrPtr)src1AddrLo;
    myconfig.dmacssau = src1AddrHi;
    myconfig.dmacdsal = (DMA_AdrPtr)dst1AddrLo;
    myconfig.dmacdsau = dst1AddrHi;

    /* Write configuration structure values to DMA control registers */
    DMA_config(myhDma, &myconfig);    

    /* Enable DMA channel to begin transfer */
    DMA_start(myhDma);
    /* Wait for FRAME status bit in DMA status register to signal */
    /* transfer is complete.                                      */
    while (!DMA_FGETH(myhDma,DMACSR,FRAME)) {
        ;   
    }

    /* We are through with DMA, so close it */
    DMA_close(myhDma); 
}

void DMA_FIFO_SDRAM(void)
{
    /* Initialize CSL library - This is REQUIRED!!! */
    CSL_init();

    /* Initialize source and destination buffers */
    for (i = 0; i <= (N - 1); i++) {
        *(DMA_dst+i) = 0;
    }

    /* Call Function For DMA Transfer */
    taskFxn();
}

interrupt void RecFifoFulIsr(void)
{
asm(" BSET INTM ");
printf(" edma start\n");
DMA_FIFO_SDRAM();
//*(int *)0x10000=0x1234;
asm(" BCLR INTM ");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -