TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320f2812的串口中断的问题

开始学习DSP的时候,在串口使用时,不通过中断接收和发送信息使用了下面的例程可以实现信息的发送与接收,但是使用了中断以后,程序不执行。

   Send_Flag = 0;

   #if SCIA_INT

/*设置中断服务程序入口地址*/

EALLOW; // This is needed to write to EALLOW protected registers

PieVectTable.TXAINT = &SCITXINTA_ISR;

PieVectTable.RXAINT = &SCIRXINTA_ISR;

EDIS;   // This is needed to disable write to EALLOW protected registers

/*开中断*/

IER |= M_INT9;

#endif

EINT;   // Enable Global interrupt INTM

ERTM; // Enable Global realtime interrupt DBGM

for(;;)

{

 if((SciaTx_Ready() == 1) && (Send_Flag == 1))

 {

  SciaRegs.SCITXBUF = Sci_VarRx;

  Send_Flag = 0;

  i++;

  if(i == j)

  {

   i = 0;

   j = 0;

  }

 }

 #if !SCIA_INT

 if(SciaRx_Ready() == 1)

 {

  Sci_VarRx[j] = SciaRegs.SCIRXBUF.all;

  Send_Flag = 1;

  j++;

  if(j == 100)

  {

   j = 0;

  }

 }

 #endif

}

所写的串口中断程序如下:

#include "DSP28_Device.h"

unsigned int Sci_VarRx[100];

unsigned int i,j;

unsigned int Send_Flag;

unsigned int * Led8  = (unsigned int *) 0x4100;

//#define SCIA_INT 1

interrupt void SCITXINTA_ISR1(void);

interrupt void SCIRXINTA_ISR1(void);

void main(void)

{

/*初始化系统*/

InitSysCtrl();

/*关中断*/

DINT;

IER = 0x0000;

IFR = 0x0000;

/*初始化PIE中断*/

InitPieCtrl();

/*初始化PIE中断矢量表*/

InitPieVectTable();

/*初始化SCIA寄存器*/

   InitSci();

   for(i = 0; i < 100; i++)

   {

    Sci_VarRx = 0;

   }

   i = 0;

   j = 0;

   Send_Flag = 0;

  #if SCIA_INT

/*设置中断服务程序入口地址*/

EALLOW; // This is needed to write to EALLOW protected registers

PieVectTable.TXAINT = &SCITXINTA_ISR1;

PieVectTable.RXAINT = &SCIRXINTA_ISR1;

EDIS;   // This is needed to disable write to EALLOW protected registers

/*开中断*/

IER |= M_INT9;

#endif

EINT;   // Enable Global interrupt INTM

ERTM; // Enable Global realtime interrupt DBGM

for(;;)

{

 if(1 && (Send_Flag == 1))

 {

  SciaRegs.SCITXBUF = Sci_VarRx[0];

  while(SciaRegs.SCICTL2.bit.TXRDY!=1);

  Send_Flag = 0;

  i++;

  if(i == j)

  {

   i = 0;

   j = 0;

  }

 }

 #if !SCIA_INT

 if(SciaRx_Ready() == 1)

 {

  Sci_VarRx[j] = SciaRegs.SCIRXBUF.all;

  Send_Flag = 1;

  j++;

  if(j == 100)

  {

   j = 0;

  }

 }

 #endif

}

}  

interrupt void  SCITXINTA_ISR1(void)

{

}

interrupt void SCIRXINTA_ISR1(void)

{

DINT;

PieCtrl.PIEACK.bit.ACK9=1;

Sci_VarRx[0] = SciaRegs.SCIRXBUF.all;

Send_Flag = 1;

j++;

// if(j == 100)

// {

//  j = 0;

// }

  *Led8=j;

SciaRegs.SCICTL1.bit.SWRESET =1;

PieCtrl.PIEIFR9.bit.INTx1=1;

EINT;

}

请问,该问题如何解决?谢谢!

jianhu liu:

断点调试一下,看执行到哪了,或者你的中断写的有问题

赞(0)
未经允许不得转载:TI中文支持网 » TMS320f2812的串口中断的问题
分享到: 更多 (0)