5509a和fifo连接,用emif端口从fifo中读取数据,dma把数据从emif端口搬到内存,每次搬运完1帧产生dma中断,但是第一次中断能正常进入,第二次中断只能读取几个数据(未满一帧),不能进入中断
#include <csl.h>
#include <csl_irq.h>
#include <csl_dma.h>
#include <csl_pll.h>
#include <csl_emif.h>
#include <csl_chip.h>
#include <stdio.h>
#include <_csl_pgpio.h>
#include <csl_gpio.h>
#include "port5509Adma.h"
#define N 4096
int *souraddr,temp;
Uint16 eventId0;
int old_intm,i;
#pragma DATA_SECTION(databuffer,"dmaMem")
unsigned int databuffer[4096],sj[4096];
#pragma DATA_SECTION(src,"shuju")
unsigned int src[4096];
//interrupt void int1(void);
interrupt void dma1_int();
//---------Function prototypes---------
/* Reference start of interrupt vector table */
/* This symbol is defined in file, vectors_IP.s55 */
extern void VECSTART(void);
void taskFxn(void);
/*锁相环的设置*/
PLL_Config myConfig = {
0, //IAI: the PLL locks using the same process that was underway
//before the idle mode was entered
1, //IOB: If the PLL indicates a break in the phase lock,
//it switches to its bypass mode and restarts the PLL phase-locking
//sequence
24, //PLL multiply value; multiply 12 times
1 //Divide by 2 PLL divide value; it can be either PLL divide value
//(when PLL is enabled), or Bypass-mode divide value
//(PLL in bypass mode, if PLL multiply value is set to 1)
};
EMIF_Config emiffig = {
0x221, //EGCR : the MEMFREQ = 00,the clock for the memory is equal to cpu frequence
// the WPE = 0 ,forbiden the writing posting when we debug the EMIF
// the MEMCEN = 1,the memory clock is reflected on the CLKMEM pin
// the NOHOLD = 1,HOLD requests are not recognized by the EMIF
0xFFFF, //EMI_RST: any write to this register resets the EMIF state machine
0x1fff, //CE0_1: CE0 space control register 1
// MTYPE = 011,Synchronous DRAM(SDRAM),16-bit data bus width
0xFFFF, //CE0_2: CE0 space control register 2
0x00FF, //CE0_3: CE0 space control register 3
// TIMEOUT = 0xFF;
0x1112, //CE1_1: CE0 space control register 1
// Asynchronous, 16Bit
0x0fff, //CE1_2: CE0 space control register 2
0x000F, //CE1_3: CE0 space control register 3
0x1FFF, //CE2_1: CE0 space control register 1
// Asynchronous, 16Bit
0xFFFF, //CE2_2: CE0 space control register 2
0x00FF, //CE2_3: CE0 space control register 3
0x1FFF, //CE3_1: CE0 space control register 1
// Asynchronous, 16Bit
0xFFFF, //CE3_2: CE0 space control register 2
0x00FF, //CE3_3: CE0 space control register 3
0x2911, //SDC1: SDRAM control register 1
// TRC = 8
// SDSIZE = 0;SDWID = 0
// RFEN = 1
// TRCD = 2
// TRP = 2
0x0410, //SDPER : SDRAM period register
// 7ns *4096
0x07FF, //SDINIT: SDRAM initialization register
// any write to this register to init the all CE spaces,
// do it after hardware reset or power up the C55x device
0x0131 //SDC2: SDRAM control register 2
// SDACC = 0;
// TMRD = 01;
// TRAS = 0101;
// TACTV2ACTV = 0001;
};
void init_dma1(unsigned int * src_data,unsigned int * dst_data)
{
unsigned long int tem;
*DMA_CCR1=0x4370;
*DMA_GCR=0x0008;
*DMA_GSCR=0x0001;
*DMA_GTCR=0x0000;
*DMA_CICR1=0x0008;
*DMA_CSDP1=0xc389;
*DMA_CEN1=0x1000;
*DMA_CFN1=0x0001;
*DMA_CSEI1=0x0000;
*DMA_CSFI1=0x0000;
*DMA_CDEI1=0x0000;
*DMA_CDFI1=0x0000;
*DMA_CSSA_L1=(unsigned int)(src_data)<<1;
tem=((unsigned long int)(src_data))>>15;
*DMA_CSSA_U1=(unsigned int)(tem);
*DMA_CDSA_L1=(unsigned int)(dst_data)<<1;
tem=((unsigned int)(dst_data))>>15;
*DMA_CDSA_U1=(unsigned int)(tem);
*DMA_CCR1=0x43f0;
}
void delay()
{
Uint32 j = 0,k = 0;
for(j = 0;j<0x1;j++)
{
for(k= 0;k<0xff;k++)
{}
}
}
main()
{
/*初始化CSL库*/
CSL_init();
/*EMIF为全EMIF接口*/
CHIP_RSET(XBSR,0x0a01);
/*设置系统的运行速度为144MHz*/
PLL_config(&myConfig);
EMIF_config(&emiffig);
taskFxn();
}
void taskFxn(void)
{
Uint16 eventId0;//定义中断ID号
/* Set Interrupt Vector Start Location */
IRQ_setVecs((Uint32)(&VECSTART));
/* Get Interrupt Event Id associated with this DMA */
eventId0 = IRQ_EVT_DMAC1;
/* Temporarily Disable All Interrupts */
old_intm = IRQ_globalDisable();
/* Enable the DMA interrupt in IER register */
IRQ_enable(eventId0);
/* Enable all maskable interrupts */
IRQ_globalEnable();
_PGPIO_pinEnable(GPIO_PIN6);
_PGPIO_pinDirection(GPIO_PIN6,1);
_PGPIO_pinWrite(GPIO_PIN6,1);
delay();
_PGPIO_pinWrite(GPIO_PIN6,0);
delay();
_PGPIO_pinWrite(GPIO_PIN6,1);
delay();
init_dma1(src,databuffer);
/*实现连续采集数据--以帧为单位*/
while(1)
{; }
}
interrupt void dma1_int()
{
temp= *(DMA_CSR1);
for(i=0;i<4096;i++)
sj[i]=databuffer[i];
asm("");
}
/******************************************************************************\
* End of pll2.c
\******************************************************************************/
.sect ".vectors"
.global _VECSTART
*------------------------------------------------------------------------------
* Global symbols referenced in this file but defined somewhere else.
* Remember that your interrupt service routines need to be referenced here.
*------------------------------------------------------------------------------
.ref _c_int00 ; C entry point
.ref _dma1_int
;.ref _flash
.align 080h ;must be aligned on page boundary
_VECSTART:
.ivec _c_int00,c54x_stk
nmi .ivec no_isr
nop_16
int0 .ivec no_isr
nop_16
int2 .ivec no_isr
nop_16
tint0 .ivec no_isr
nop_16
rint0 .ivec no_isr
nop_16
rint1 .ivec no_isr
nop_16
xint1 .ivec no_isr
nop_16
usb .ivec no_isr
nop_16
dmac1 .ivec _dma1_int
nop_16
dspint .ivec no_isr
nop_16
int3 .ivec no_isr
nop_16
rint2 .ivec no_isr
nop_16
xint2 .ivec no_isr
nop_16
dmac4 .ivec no_isr
nop_16
dmac5 .ivec no_isr
nop_16
int1 .ivec no_isr
nop_16
xint0 .ivec no_isr
nop_16
dmac0 .ivec no_isr
nop_16
int4 .ivec no_isr
nop_16
dmac2 .ivec no_isr
nop_16
dmac3 .ivec no_isr
nop_16
tint1 .ivec no_isr
nop_16
iic .ivec no_isr
nop_16
berr .ivec no_isr
nop_16
dlog .ivec no_isr
nop_16
rtos .ivec no_isr
nop_16
iv27 .ivec no_isr
nop_16
iv28 .ivec no_isr
nop_16
iv29 .ivec no_isr
nop_16
siv30 .ivec no_isr
nop_16
siv31 .ivec no_isr
nop_16
.text
.def no_isr
no_isr:
b #no_isr