mcbsp中断rint 和xint中断进不去??谢谢 #include <stdio.h> #include <csl.h> #include <csl_mcbsp.h> #include <DEC6713.h> extern far void vectors(); //---------Global constants--------- #define N 10
/* create a config structure for digital loopback mode */ static MCBSP_Config ConfigLoopback = { /* Serial Port Control Register (SPCR) */ MCBSP_SPCR_RMK( MCBSP_SPCR_FREE_YES, MCBSP_SPCR_SOFT_YES, MCBSP_SPCR_FRST_YES, MCBSP_SPCR_GRST_YES, MCBSP_SPCR_XINTM_XRDY , MCBSP_SPCR_XSYNCERR_NO , MCBSP_SPCR_XRST_NO, MCBSP_SPCR_DLB_ON, MCBSP_SPCR_RJUST_RZF, MCBSP_SPCR_CLKSTP_DISABLE, MCBSP_SPCR_DXENA_OFF, MCBSP_SPCR_RINTM_RRDY, MCBSP_SPCR_RSYNCERR_NO, MCBSP_SPCR_RRST_NO ), /* Receive Control Register (RCR) */ MCBSP_RCR_RMK( MCBSP_RCR_RPHASE_SINGLE, MCBSP_RCR_RFRLEN2_OF(0), MCBSP_RCR_RWDLEN2_8BIT, MCBSP_RCR_RCOMPAND_MSB, MCBSP_RCR_RFIG_YES, MCBSP_RCR_RDATDLY_0BIT, MCBSP_RCR_RFRLEN1_OF(0), MCBSP_RCR_RWDLEN1_32BIT, MCBSP_RCR_RWDREVRS_DISABLE ),
/* Transmit Control Register (XCR) */ MCBSP_XCR_RMK( MCBSP_XCR_XPHASE_SINGLE, MCBSP_XCR_XFRLEN2_OF(0), MCBSP_XCR_XWDLEN2_8BIT, MCBSP_XCR_XCOMPAND_MSB, MCBSP_XCR_XFIG_YES, MCBSP_XCR_XDATDLY_0BIT, MCBSP_XCR_XFRLEN1_OF(0),
MCBSP_XCR_XWDLEN1_32BIT,
MCBSP_XCR_XWDREVRS_DISABLE ), /*serial port sample rate generator register(SRGR) */ MCBSP_SRGR_RMK( MCBSP_SRGR_GSYNC_FREE, MCBSP_SRGR_CLKSP_RISING, MCBSP_SRGR_CLKSM_INTERNAL, MCBSP_SRGR_FSGM_DXR2XSR, MCBSP_SRGR_FPER_OF(63), ), MCBSP_MCR_DEFAULT, /* Using default value of MCR register */ MCBSP_RCER_DEFAULT,/* Using default value of RCER register */ MCBSP_XCER_DEFAULT,/* Using default value of XCER register */ /* serial port pin control register(PCR) */ MCBSP_PCR_RMK( MCBSP_PCR_XIOEN_SP, /* Transmitter in general-purpose I/O mode - only when XRST = 0 in SPCR - (XIOEN) MCBSP_PCR_XIOEN_SP - CLKS pin is not a general purpose input. DX pin is not a general purpose output.FSX and CLKX are not general-purpose I/Os. MCBSP_PCR_XIOEN_GPIO - CLKS pin is a general-purpose input. DX pin is a general-purpose output. FSX and CLKX are general-purpose I/Os. These serial port pins do not perform serial port operation. */ MCBSP_PCR_RIOEN_SP, /* Receiver in general-purpose I/O mode - only when RRST = 0 in SPCR -(RIOEN) MCBSP_PCR_RIOEN_SP - DR and CLKS pins are not general-purpose inputs. FSR and CLKR are not general-purpose I/Os and perform serial port operation. MCBSP_PCR_RIOEN_GPIO - DR and CLKS pins are general-purpose inputs. FSR and CLKR are general-purpose I/Os. These serial port pins do not perform serial port operation. */ MCBSP_PCR_FSXM_INTERNAL, /* Transmit frame synchronization mode(FSXM) MCBSP_PCR_FSXM_EXTERNAL - Frame synchronization signal is provided by an external source. FSX is an input pin. MCBSP_PCR_FSXM_INTERNAL - Frame synchronization generation is determined by the sample rate generator frame synchronization mode bit FSGM in the SRGR. */ MCBSP_PCR_FSRM_EXTERNAL, /* Receive frame synchronization mode (FSRM) MCBSP_PCR_FSRM_EXTERNAL - Frame synchronization signals are generated by an external device. FSR is an input pin. MCBSP_PCR_FSRM_INTERNAL - Frame synchronization signals are generated internally by the sample rate generator. FSR is an output pin except when GSYNC = 1 in SRGR. */ MCBSP_PCR_CLKXM_OUTPUT, /* Transmitter clock mode (CLKXM) MCBSP_PCR_CLKXM_INPUT - Transmitter clock is driven by an external clock with CLKX as an input pin. MCBSP_PCR_CLKXM_OUTPUT - CLKX is an output pin and is driven by the internal sample rate generator. During SPI mode : MCBSP_PCR_CLKXM_INPUT - McBSP is a slave and (CLKX) is driven by the SPI master in the system. CLKR is internally driven by CLKX. MCBSP_PCR_CLKXM_OUTPUT - McBSP is a master and generates the transmitter clock (CLKX) to drive its receiver clock (CLKR) and the shift clock of the SPI-compliant slaves in the system. */ MCBSP_PCR_CLKRM_INPUT, /* Receiver clock mode (CLKRM) Case 1: Digital loopback mode not set in SPCR MCBSP_PCR_CLKRM_INPUT - Receive clock (CLKR) is an input driven by an external clock. MCBSP_PCR_CLKRM_OUTPUT - CLKR is an output pin and is driven by the sample rate generator. Case 2: Digital loopback mode set in SPCR MCBSP_PCR_CLKRM_INPUT - Receive clock is driven by the transmit clock (CLKX), which is based on the CLKXM bit in PCR. CLKR is in high impedance. MCBSP_PCR_CLKRM_INPUT - CLKR is an output pin and is driven by the transmit clock. The transmit clock is derived from CLKXM bit in the PCR.*/ MCBSP_PCR_CLKSSTAT_0, /* CLKS pin status(CLKSSTAT) MCBSP_PCR_CLKSSTAT_0 MCBSP_PCR_CLKSSTAT_1 */ MCBSP_PCR_DXSTAT_0, /* DX pin status(DXSTAT) MCBSP_PCR_DXSTAT_0 MCBSP_PCR_DXSTAT_1 */ MCBSP_PCR_FSXP_ACTIVEHIGH, /* Transmit frame synchronization polarity(FSXP) MCBSP_PCR_FSXP_ACTIVEHIGH - Frame synchronization pulse FSX is active high MCBSP_PCR_FSXP_ACTIVELOW - Frame synchronization pulse FSX is active low */ MCBSP_PCR_FSRP_ACTIVEHIGH, /* Receive frame synchronization polarity(FSRP) MCBSP_PCR_FSRP_ACTIVEHIGH - Frame synchronization pulse FSR is active high MCBSP_PCR_FSRP_ACTIVELOW - Frame synchronization pulse FSR is active low */ MCBSP_PCR_CLKXP_RISING, /* Transmit clock polarity(CLKXP) MCBSP_PCR_CLKXP_RISING - Transmit data driven on rising edge of CLKX MCBSP_PCR_CLKXP_FALLING - Transmit data driven on falling edge of CLKX */ MCBSP_PCR_CLKRP_FALLING /* Receive clock polarity(CLKRP) MCBSP_PCR_CLKRP_FALLING - Receive data sampled on falling edge of CLKR MCBSP_PCR_CLKRP_RISING - Receive data sampled on rising edge of CLKR */ ) };
static Uint32 rcvEventId, xmtEventId; //Uint16 rcvEventID, xmtEventID; Uint32 xmt[N],rcv[N]; volatile Uint16 XfrCnt = 0; Uint16 err = 0; Uint16 old_intm; MCBSP_Handle hMcbsp; Uint16 i;
void taskFxn(void); /* ---------------------------------------------------------------------------*/ //---------main routine--------- void main(void) { Uint16 i;
/* Initialize CSL library - This is REQUIRED !!! */ CSL_init(); /* Set IVPD/IVPH to start of interrupt vector location */ // IRQ_setVecs((Uint32)(&VECSTART));
for (i = 0; i <= N - 1; i++) { xmt = i; rcv = 0; }
/* Call function to effect transfer */ taskFxn(); }
void taskFxn(void) { Uint16 i;
old_intm = IRQ_globalDisable();
/* Let's open up serial port 1 */ hMcbsp = MCBSP_open(MCBSP_DEV1, MCBSP_OPEN_RESET);
/* Get EventId's associated with MCBSP Port 0 receive and transmit */ /* The event Id's are used to communicate with the CSL interrupt */ /* module functions. */ rcvEventId = MCBSP_getRcvEventId(hMcbsp); xmtEventId = MCBSP_getXmtEventId(hMcbsp); IRQ_setVecs(vectors); /* point to the IRQ vector table */
/* Clear any pending receive or transmit interrupts */ IRQ_clear(rcvEventId); IRQ_clear(xmtEventId); /* Place address of interrupt service routines at */ /* associated vector location */ //IRQ_plug(rcvEventId, &readIsr); //IRQ_plug(xmtEventId, &writeIsr); /* Map timer events to physical interrupt number */ IRQ_map(rcvEventId, 14);
IRQ_map(xmtEventId, 15);
/* We'll set it up for digital loopback, 32bit mode. We have */ /* to setup the sample rate generator to allow self clocking. */ MCBSP_config(hMcbsp,&ConfigLoopback);
/* Enable the MCBSP receive and transmit interrupts */ IRQ_enable(rcvEventId); IRQ_enable(xmtEventId);
/* Now that the port is setup, let's enable it in steps. */ MCBSP_start(hMcbsp,MCBSP_RCV_START | MCBSP_XMIT_START | MCBSP_SRGR_START| MCBSP_SRGR_FRAMESYNC, MCBSP_SRGR_DEFAULT_DELAY);
/* Prime MCBSP transmit */ while(!MCBSP_xrdy(hMcbsp)){ ; } MCBSP_write(hMcbsp,xmt[3]); // while(!MCBSP_rrdy(hMcbsp)){ ; }
// x = MCBSP_read(hMcbsp);XfrCnt
/* Enable all masked interrupts */ IRQ_globalEnable();
/* Wait for transfer of data */ while (XfrCnt < 10) { ; } /*------------------------------------------*\ * Compare values \*------------------------------------------*/ for(i = 0; i <= N - 1; i++){ if (rcv != xmt){ ++err; break; } }
printf ("%s\n",err?"TEST FAILED" : "TEST PASSED");
/* Restore old value of INTM */ IRQ_globalRestore(old_intm); /* We're done with MCBSP, so close it */ MCBSP_close(hMcbsp); }
/************************************************************************\ name: Interrupt Service Routine c_int14
purpose: ISR to service TIMERINT1. vecs.asm must be modified to include c_int14 entry. inputs: n/a
returns: n/a \************************************************************************/
interrupt void c_int15(void) { /* * Disable this ISR's interrupt before the write to the McBSP * since another interrupt will be generated as soon as the write * completes, which happens very quickly due to the loopback to * the McBSP receive. */ IRQ_disable(xmtEventId); MCBSP_write(hMcbsp,xmt[XfrCnt]); }
interrupt void c_int14(void) {
rcv[XfrCnt] = MCBSP_read32(hMcbsp); ++XfrCnt; if (XfrCnt == N) { IRQ_disable(rcvEventID); IRQ_disable(xmtEventID); MCBSP_reset(hMcbsp); } else { IRQ_enable(xmtEventID); } }
/******************************************************************************\ * End of DEC6713_TIMER.c \******************************************************************************/
这个我编写的TI 合纵达6713 的 MCBSP中断测试程序, int_14为mcbsp中断读操作 int_15为中断写操作 程序最后停在while (XfrCnt < 10) { ; } 处; 就是不进中断; 中断标志位 MCBSP_rrdy(hMcbsp) MCBSP_xrdy(hMcbsp) 均改变了,就是进不去啊 请大家帮忙看看 谢谢!!
|
|