打印

mcbsp中断rint 和xint中断进不去??大家请指点一下,谢谢!

[复制链接]
3589|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yixizhe|  楼主 | 2008-8-17 10:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
mcbsp, TE, TI, pc, AN

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)
        均改变了,就是进不去啊             
  
 请大家帮忙看看  谢谢!!







相关帖子

沙发
yixizhe|  楼主 | 2008-8-17 10:56 | 只看该作者

补充一下,我使用的是ti dsp 6713

补充一下,我使用的是ti dsp 6713

使用特权

评论回复
板凳
yixizhe|  楼主 | 2008-8-17 11:00 | 只看该作者

以下是6713中断向量表设置,请大家多多指导,不胜感激!

*
* Copyright (C) 2003 Texas Instruments Incorporated
* All Rights Reserved
*
*
*---------vecs_timer1.asm---------
*
* Assembly file to set up interrupt service table (IST)
*

*------------------------------------------------------------------------------
* Global symbols defined here and exported out of this file
*------------------------------------------------------------------------------
   .global _vectors
   .global _c_int00
   .global _vector1
   .global _vector2
   .global _vector3
   .global _vector4
   .global _vector5
   .global _vector6
   .global _vector7
   .global _vector8
   .global _vector9      
   .global _vector10 
   .global _vector11   
   .global _vector12  
   .global _vector13   
   .global _c_int14  ; Hookup the c_int14 ISR in main()
   .global _c_int15  ; Hookup the c_int15 ISR in main()

*------------------------------------------------------------------------------
* Global symbols referenced in this file but defined somewhere else. 
* Remember that your interrupt service routines need to be referenced here.
*------------------------------------------------------------------------------
   .ref _c_int00

*------------------------------------------------------------------------------
* This is a macro that instantiates one entry in the interrupt service table.
*------------------------------------------------------------------------------
VEC_ENTRY .macro addr
    STW   B0,*--B15
    MVKL  addr,B0
    MVKH  addr,B0
    B     B0
    LDW   *B15++,B0
    NOP   2
    NOP   
    NOP   
   .endm


*------------------------------------------------------------------------------
* This is a dummy interrupt service routine used to initialize the IST.
*------------------------------------------------------------------------------
_vec_dummy:
  B    B3
  NOP  5

*------------------------------------------------------------------------------
* This is the actual interrupt service table (IST). It is properly aligned and
* is located in the subsection .text:vecs. This means if you don't explicitly
* specify this section in your linker command file, it will default and link
* into the .text section. Remember to set the ISTP register to point to this
* table.
*------------------------------------------------------------------------------
 .sect ".text:vecs"
 .align 1024

_vectors:
_vector0:   VEC_ENTRY _c_int00    ;RESET
_vector1:   VEC_ENTRY _vec_dummy  ;NMI
_vector2:   VEC_ENTRY _vec_dummy  ;RSVD
_vector3:   VEC_ENTRY _vec_dummy
_vector4:   VEC_ENTRY _vec_dummy
_vector5:   VEC_ENTRY _vec_dummy
_vector6:   VEC_ENTRY _vec_dummy
_vector7:   VEC_ENTRY _vec_dummy
_vector8:   VEC_ENTRY _vec_dummy
_vector9:   VEC_ENTRY _vec_dummy
_vector10:  VEC_ENTRY _vec_dummy
_vector11:  VEC_ENTRY _vec_dummy
_vector12:  VEC_ENTRY _vec_dummy
_vector13:  VEC_ENTRY _vec_dummy
_vector14:  VEC_ENTRY _c_int14  ; Hookup the c_int14 ISR in main()
_vector15:  VEC_ENTRY _c_int15  ; Hookup the c_int15 ISR in main()

*------------------------------------------------------------------------------
以上是6713  中断向量表。
请大家多多指导!不胜感激!

使用特权

评论回复
地板
千客骚人| | 2008-8-21 17:47 | 只看该作者

原因

你看看是不是这个原因,因为在c6000dsp中,msbsp,i2c....等外设默认情况下是不允许用户使用的,也就是说被锁住了,你必须在外设控制寄存器(PERCFG)中开锁才行。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

7

帖子

0

粉丝