我是新手 麻烦高人指点啊 现在是我连上串口以后 跑马灯正常,按PC机的任意键都会使其停在某一位置,然后就没任何反应了,另外,上电后,PC机只是收到两个' * ' 并不是****UART IRQ TEST**** 程序如下: #include "system.h" #include "io.h" #include "alt_types.h" #include <stdio.h> //#include "altera_avalon_jtag_uart_regs.h" #include "sys/alt_irq.h" unsigned char New_Command=0; unsigned int data; void UART_0_irq(void *context,alt_u32 interrupt) { data=IORD(UART_0_BASE,0x00); //读取rxdata寄存器 IOWR(UART_0_BASE,0x02,0x00);// 清除status寄存器 New_Command=1; } int main (void) { unsigned char led=0x02; unsigned char dir=0x00; volatile int i=0; printf("****UART IRQ TEST****\n"); IOWR(UART_0_BASE,0x03,0x80); //设置control寄存器 //IOWR(UART_0_BASE,0x00,0x00); //clear rxdata IOWR(UART_0_BASE,0x02,0x00);// 清除status寄存器 if(alt_irq_register(UART_0_IRQ, NULL,UART_0_irq)) printf("interrupt register FAIL! \n"); while(1) { if (led & 0x11) { dir = (dir ^ 0x1); } if (dir) { led = led >> 1; } else { led = led << 1; } IOWR(LED_BASE,0x00,led); i = 0; while (i<20000) i++; if(New_Command==1) { printf("***Receive data***\n"); New_Command=0; i=0; switch(data) { case 1: IOWR(LED_BASE,0x00,21); printf("****Do the first thing****\n"); while(i<900000) i++; i=0; break; case 2: IOWR(LED_BASE,0x00,10); printf("****Do the second thing****\n"); while(i<900000) i++; i=0; break; default: break; } } } return 0; } 我也使用过#include "altera_avalon_uart_regs.h"里面的初始化函数 但是效果使一样的,设置串口是不是不能直接使用我上面使用的的函数啊 IOWR(),和IORD(); 谢谢了!
[em06][em06][em06] |