我用的c5402,中断方式从MCBSP口收发数据,但是中断程序不响应,请求高手指点一下。
程序如下:
头文件
typedef unsigned int u16;
typedef signed int s16;
/* Register Definition MCBSP */
#define SPSA_ADDR(port) (port ? 0x48 : 0x38)
#define SPSD_ADDR(port) (port ? 0x49 : 0x39)
#define DRR2_ADDR(port) (port ? 0x40 : 0x20)
#define DRR1_ADDR(port) (port ? 0x41 : 0x21)
#define DXR2_ADDR(port) (port ? 0x42 : 0x22)
#define DXR1_ADDR(port) (port ? 0x43 : 0x23)
#define MCBSP_ACCSUB_ADDR(port) (port ? 0x49 : 0x39)
#define SPCR1_SUBADDR 0x00
#define SPCR2_SUBADDR 0x01
#define RCR1_SUBADDR 0x02
#define RCR2_SUBADDR 0x03
#define XCR1_SUBADDR 0x04
#define XCR2_SUBADDR 0x05
#define SRGR1_SUBADDR 0x06
#define SRGR2_SUBADDR 0x07
#define MCR1_SUBADDR 0x08
#define MCR2_SUBADDR 0x09
#define RCERA_SUBADDR 0x0A
#define RCERB_SUBADDR 0x0B
#define XCERA_SUBADDR 0x0C
#define XCERB_SUBADDR 0x0D
#define PCR_SUBADDR 0x0E
#define bsp_SPCR11 0x0000
#define bsp_SPCR21 0x0000
#define bsp_PCR1 0x0a00
#define bsp_RCR11 0x0040
#define bsp_RCR21 0x0041
#define bsp_XCR11 0x0040
#define bsp_XCR21 0x0041
#define bsp_SRGR11 0x0009
#define bsp_SRGR21 0x30f9
#define bsp_MCR11 0x0000
#define bsp_MCR21 0x0000
//---------CPU -----------
//ST1 addr:0x0007 Status register 1 ST1[13]=XF
#define reg_ST1 0x0007
#define PMST 0x001D
#define SWWSR 0x0028
#define SWCR 0x002B
#define BSCR 0x0029
#define CLKMD 0x0058
#define IMR 0x0000
#define IFR 0x0001
#define PMST_VAL 0x00A0 //interupt vectors from 0x80
#define SWWSR_VAL 0x7fff
#define SWCR_VAL 0x0001
#define BSCR_VAL 0x8802
#define CLKMD_VAL 0xf007
volatile char *LINE_ADDR = (volatile char*)0x4000;
初始化文件:
void init_board(void)
{
unsigned int i;
*(volatile u16 *)CLKMD = 0x0000;
while(*(volatile u16 *)CLKMD & 0x0001){};
*(volatile u16 *)CLKMD = CLKMD_VAL;
*(volatile u16 *)PMST = PMST_VAL;
*(volatile u16 *)SWWSR =SWWSR_VAL;
*(volatile u16 *)SWCR =SWCR_VAL;
*(volatile u16 *)BSCR =BSCR_VAL;
asm(" SSBX INTM");
*(volatile u16 *)SPSA_ADDR(1)=SPCR1_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_SPCR11;
*(volatile u16 *)SPSA_ADDR(1)=SPCR2_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_SPCR21;
*(volatile u16 *)SPSA_ADDR(1)=RCR1_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_RCR11;
*(volatile u16 *)SPSA_ADDR(1)=RCR2_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_RCR21;
*(volatile u16 *)SPSA_ADDR(1)=XCR1_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_XCR11;
*(volatile u16 *)SPSA_ADDR(1)=XCR2_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_XCR21;
*(volatile u16 *)SPSA_ADDR(1)=SRGR1_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_SRGR11;
*(volatile u16 *)SPSA_ADDR(1)=SRGR2_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_SRGR21;
*(volatile u16 *)SPSA_ADDR(1)=MCR1_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_MCR11;
*(volatile u16 *)SPSA_ADDR(1)=MCR2_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_MCR21;
*(volatile u16 *)SPSA_ADDR(1)=PCR_SUBADDR;
*(volatile u16 *)SPSD_ADDR(1)=bsp_PCR1;
*(volatile u16 *)SPSA_ADDR(1)=SPCR2_SUBADDR; //启动采样率发生器
*(volatile u16 *)SPSD_ADDR(1)|=0x0040;
*(volatile u16 *)SPSA_ADDR(1)=SPCR2_SUBADDR; //启动帧同步
*(volatile u16 *)SPSD_ADDR(1)|=0x0080;
*(volatile u16 *)SPSA_ADDR(1)=SPCR2_SUBADDR; //启动发送器
*(volatile u16 *)SPSD_ADDR(1)|=0x0001;
*(volatile u16 *)SPSA_ADDR(1)=SPCR1_SUBADDR; //启动接受器
*(volatile u16 *)SPSD_ADDR(1)=0x0001;
*(volatile u16 *)IMR=0x0000;
*(volatile u16 *)IFR=0x3FFF;
*(volatile u16 *)IMR=0x3FFF;
asm(" RSBX INTM");
for(i=0;i<80;i++)
{
LINE_ADDR[i]=0x0;
}
// init_ad50();
}
ASM文件:
.sect ".vectors"
.ref _c_int00
.global _McBSP_brint1
.align 0x80
RESET:
BD _c_int00
STM #128, SP
nmi: RETE
NOP
NOP
NOP
sint17 .space 4*16
sint18 .space 4*16
sint19 .space 4*16
sint20 .space 4*16
sint21 .space 4*16
sint22 .space 4*16
sint23 .space 4*16
sint24 .space 4*16
sint25 .space 4*16
sint26 .space 4*16
sint27 .space 4*16
sint28 .space 4*16
sint29 .space 4*16
sint30 .space 4*16
int0:RETE
NOP
NOP
NOP
int1:RETE
NOP
NOP
NOP
int2:RETE
NOP
NOP
NOP
tint0:RETE
NOP
NOP
NOP
brint0:RETE
NOP
NOP
NOP
bxint0:RETE
NOP
NOP
NOP
DMAC0:RETE
NOP
NOP
NOP
tint1:RETE
NOP
NOP
NOP
int3:RETE
NOP
NOP
NOP
hpint:RETE
NOP
NOP
NOP
brint1:B _McBSP_brint1
NOP
NOP
bxint1:RETE
NOP
NOP
NOP
DMAC4:RETE
NOP
NOP
NOP
DMAC5:RETE
NOP
NOP
NOP
.end
CMD文件:
MEMORY
{
PAGE 0:
VECS(RXI): origin=0x80, length=0x0080
PROG(RWXI): origin=0x100, length=0x2000
PAGE 1: DATA(RWI): origin=0x2000, length=0x2000
}
SECTIONS
{
.text {} > PROG PAGE 0
.cinit {} > PROG PAGE 0
.pinit {} > PROG PAGE 0
.vectors{} > VECS PAGE 0
.stack {} > DATA PAGE 1
.bss {} > DATA PAGE 1
.const {} > DATA PAGE 1
.switch {} > DATA PAGE 1
.sysmem {} > DATA PAGE 1
.cio {} > DATA PAGE 1
.far {} > DATA PAGE 1
}
主程序:
#include "agc_face.h"
#include "agc_func.h"
const s16 cWriteBuffer[16]={
0x000a,0x2201,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f
};
s16 RdBuffer[16],WrBuffer[16];
s16 dIn,dOut;
s16 intDataIn;
s16 Read_BSP1(void);
void Write_BSP1(s16);
void Led_Light(void);
int AGC_audio(int);
void Write_dpram(void);
interrupt void McBSP_brint1();
// Main program
void main()
{
int cnt0=0;
// int cnt2=0;
// int cnt3=0;
init_board();
while (1)
{
// dOut=AGC_audio(dIn);
// Write_dpram();
dOut=cWriteBuffer[cnt0];
Write_BSP1(dOut);
// dIn=Read_BSP1();
// RdBuffer[cnt0]=dIn;
// LINE_ADDR[cnt0]=RdBuffer[cnt0]&0xFF;
if(cnt0>=15)cnt0=0;
cnt0++;
Led_Light();
}
}
interrupt void McBSP_brint1() //中断方式读取数据
{
asm(" SSBR INTM");
intDataIn=*(volatile u16*)DRR1_ADDR(1);
asm(" RSBR INTM");
}
s16 Read_BSP1(void) //查询方式读取数据
{
s16 dDataIn;
*(volatile u16 *)SPSA_ADDR(1)=SPCR1_SUBADDR; //Receive Data from McBSP1
while(!((*(volatile u16 *)SPSD_ADDR(1)) & 0x0002)){};
dDataIn=*(volatile u16*)DRR1_ADDR(1);
return dDataIn;
}
void Write_BSP1(s16 dDataOut)
{
*(volatile u16 *)SPSA_ADDR(1)=SPCR2_SUBADDR; //Transmit Data To McBSP1
while(!((*(volatile u16 *)SPSD_ADDR(1)) & 0x0002)){};
*(volatile u16 *)DXR1_ADDR(1)=dDataOut;
}
void Led_Light(void)
{
static int i=0;
if(i>1024)
{
// *(int *)(0x0007)^=0x2000;
*(volatile u16 *)reg_ST1 ^= 0x2000; //Every 1024 times XF changed
i=0;
}
i++;
}
发送数据采用查询方式发送cWriteBuffer中的数据,采用中断方式读回数据,收DR与DX自环,程序一直不响应中断,请高手帮忙看看,谢谢 |