|
///串口接收中断程序
static void __irq ReInt(void)
{
U8 datatemp;
U32 r;
EnterCritical(&r);
if(rINTPND==BIT_UART0)
{
ClearPending(BIT_UART0);
datatemp=RdURXH0();
Uart_Printf("\nThis is your typed char \n");
Uart_SendByte(datatemp);
}
ExitCritical(&r);
}
///串口接收中断初始化
void Uart0_int_init(void)
{
ClearPending(BIT_UART0);
pISR_UART0 = (U32)ReInt;
EnableIrq(BIT_UART0);
}
///串口初始化
void Uart_Init(int pclk,int baud)
{
int i;
if(pclk == 0)
pclk = PCLK;
rUFCON0 = 0x0; //UART channel 0 FIFO control register, FIFO disable
rUFCON1 = 0x0; //UART channel 1 FIFO control register, FIFO disable
rUFCON2 = 0x0; //UART channel 2 FIFO control register, FIFO disable
rUMCON0 = 0x0; //UART chaneel 0 MODEM control register, AFC disable
rUMCON1 = 0x0; //UART chaneel 1 MODEM control register, AFC disable
//UART0
rULCON0 = 0x3; //Line control register : Normal,No parity,1 stop,8 bits
// [10] [9] [8] [7] [6] [5] [4] [3:2] [1:0]
// Clock Sel, Tx Int, Rx Int, Rx Time Out, Rx err, Loop-back, Send break, Transmit Mode, Receive Mode
// 0 1 0 , 0 1 0 0 , 01 01
// PCLK Level Pulse Disable Generate Normal Normal Interrupt or Polling
rUCON0 = 0x245; // Control register
rUBRDIV0=( (int)(pclk/16./baud+0.5) -1 ); //Baud rate divisior register 0
for(i=0;i<100;i++);
}
不知道哪里出错了,就是进入不了中断 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|