三生石 发表于 2011-9-13 17:15:56

TQ2440不能进入串口中断????

查询方式有用!
中断设置如下
void Uart0ISRInit(void)
{
    rGPHCON = 0x00faaa;
    rGPHUP = 0x7ff;
    rULCON0 = 0x3;
    rUCON0 = 0x5;
    rUFCON0 = 0;
    rUMCON0 = 0;
    rUBRDIV0 = 26;
    rSUBSRCPND=0x3;
    rSRCPND=0x1<<28; // open uart 中断
    rINTPND=0x1<<0x28;
   
    rINTSUBMSK=~(0x3);
    rINTMSK=~(0x1<<0x28);//不屏蔽UART0中断   
}
void __irq uartISP(void)
{
   
   
    char ch;
   
    Uart_Printf("In UART0 irq.");
   
   
    rSUBSRCPND |= 0x3;
           rSRCPND=0x1<<28; // open uart
    rINTPND=0x1<<0x28;
   
    if(rUTRSTAT0 & 1) //接收数据处理部分
    {
      ch = rURXH0; //接收字节数据
      if(ch==0x55)
      rGPBDAT = ~0x61; //亮两个LED
      else
      rUTXH0 = ch; //发送字节数据
    }
    else //发送数据处理部分
    {
      rGPBDAT = ~0x1e1; //亮4个LED输入非有效数据(汉字和一些特殊字符)就会亮起来了
      Led_Display(2);
    }   
}
pISR_UART0=(unsigned)uartISP;





void Main(void)
{
        char *mode;
        int i;
        U8 key;
        U32 mpll_val = 0 ;

        Port_Init();//端口初始化
       
//        Isr_Init();   //中断初始化
       

        key = 14;
        mpll_val = (92<<12)|(1<<4)|(1);

        //init FCLK=400M, so change MPLL first
        ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
        ChangeClockDivider(key, 12);
        cal_cpu_bus_clk();
       
        Uart0ISRInit();
       
        consoleNum = 0;        // 选择一个串口进行调试.
//        Uart_Init( 0,115200 );//时钟,波特率
        Uart_Select( consoleNum );//选择哪一个串口
       
        Beep(2000, 100);          //蜂鸣器响,初始化完成。
       
        Uart_SendByte('\n');
        Uart_Printf("<***************************************>\n");

        Led_Display(8);
       
        Clk1_Disable();
       
   // Uart0ISRInit();
        pISR_UART0=(unsigned)uartISP;
        while(1)
        {

                //Led_Display(4);               
        }                 

}
页: [1]
查看完整版本: TQ2440不能进入串口中断????