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

📄 sendfifo.c

📁 dsp vc5509 的多通道SPI通信程序
💻 C
字号:
#include <stdio.h>
#include "registers.h"
#include <csl.h>
#include <csl_irq.h>
#include <csl_dma.h>
//---------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 myhDma1;
DMA_Config  myconfig1 = { 
  DMA_DMACSDP_RMK(
    DMA_DMACSDP_DSTBEN_NOBURST,
    DMA_DMACSDP_DSTPACK_OFF,
    DMA_DMACSDP_DST_EMIF,
    DMA_DMACSDP_SRCBEN_NOBURST,
    DMA_DMACSDP_SRCPACK_OFF,
    DMA_DMACSDP_SRC_DARAM,
    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_SEND_src,                     /* DMACSSAL */
    0,                                     /* DMACSSAU */
    (DMA_AdrPtr)DMA_SEND_dst,                     /* DMACDSAL */
    0,                                     /* DMACDSAU */
    2048,                                     /* DMACEN   */
    1,                                     /* DMACFN   */
    0,                                     /* DMACFI   */
    0                                      /* DMACEI   */
};


void taskFxn1(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 */
    myhDma1 = 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_SEND_src)) >> 15) & 0xFFFFu;
    src1AddrLo = (Uint16)(((Uint32)(DMA_SEND_src)) << 1) & 0xFFFFu;
    dst1AddrHi = (Uint16)(((Uint32)(DMA_SEND_dst)) >> 15) & 0xFFFFu;
    dst1AddrLo = (Uint16)(((Uint32)(DMA_SEND_dst)) << 1) & 0xFFFFu;



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

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

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

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

void DMA_FIFO(void)
{
    /* Initialize CSL library - This is REQUIRED!!! */
    CSL_init();
 
    /* Call Function For DMA Transfer */
    taskFxn1();
}

void send(void)
{int i,j;
Uint32* p;
//Uint32 sin[16] = {625000 ,    605970 ,    551777 ,    470671 ,    375000 ,    279329 ,    198223 ,    144030 ,    125000 ,    144030 ,    198223 ,    279329 ,    375000 ,    470671 ,    551777 ,    605970};
//Uint32 sin[16] = {0x00f300,0x00ea00,0x00e100,0x00d800,0x00d500,0x00e000,0x00f500,0x000700,0x001800,0x002200,0x002700,0x002400,0x001b00,0x001000,0x000600,0x00fd00};
Uint32 sin[16] = {0x0fffff,0x0fffff,0x0fffff,0x0fffff,0x0fffff,0x0fffff,0x0fffff,0x0fffff,0x000,0x000,0x0000,0x000,0x0000,0x000,0x000,0x000};
for(i=0;i<256;i++)
for(j=0;j<16;j++)
*((Uint32*)0x0100000) = sin[j];
}
interrupt void SendFifoEmpIsr(void)
{
asm(" BSET INTM ");
printf(" \ndma send\n");
//while(1)
send();
//DMA_FIFO();
//send();
*IFR0 = *IFR0;
//*(int *)0x10000=0x1234;
asm(" BCLR INTM ");
}


⌨️ 快捷键说明

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