This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

6747串口中断

仿照6748的例程写了一个6747uart0中断,功能主要是首先接收数据,然后用串口中断发送一个数组,可以正常进入接收,我在接收中给发送寄存器赋值,触发发送中断,单步执行,可以进入中断服务函数,但是变量ID没有检测到变化,并且是直接到if语句,前面的ID 和中断清零没有运行,然后直接退出了中断,串口中断也自己清除了,但是没有发送数据,代码如下

interrupt void  UART0()//uart interrupt
{

	volatile unsigned int ID;

	  Uint8 dumy=0;
	  Uint8 datareceive=0;
	  //CSR&= 0xfffe;
	  ID = ((uartid->regs->IIR&(0xE))>>1);
	  EVTCLR1|=0x40;//clear the uart0 interrupt flag
	  //CSR&= 0xfffe;	             // 关中断 GIE=0
	  //asm(" NOP 1 ");
	  //ICR = 0xFFF0;                // 清除中断标志ICR

	 // switch((uartid->regs->IIR&(0xE))>>1)
	 // {
	  if(((uartid->regs->IIR&(0xE))>>1)==0)
	  { }

	  if(((uartid->regs->IIR&(0xE))>>1)==1)   //send interrupt
	  	  {

			  length=14;
			  if(count<length)
			  {
				  uartid->regs->THR=DownOrder[count];
				  count++;
			  }
			  if(count>=length)
			  {
				  //uartid->regs->IER&=~(1<1);
				  dumy=uartid->regs->IIR;
				  UART0_Recive;
				  count=1;

			  }


	  	  }

	  if(((uartid->regs->IIR&(0xE))>>1)==2)  //receive
	  {
		  	datareceive = uartid->regs->RBR;
	    	ReceiveOrder[Relength]=datareceive;
	    	Relength++;


			if(datareceive==0x80)
			{
				UART0_Send;
				 
					  uartid->regs->THR=DownOrder[0];
					  Uart0Flag=0;
			 
			 }


      }


	  if(((uartid->regs->IIR&(0xE))>>1)==3)
	  {
		  ID = uartid->regs->THR;

	  }



}