- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello~~~~~~~~
my tool is quartus 9.0sp2 and ide9.0sp2. when i use uart receiving interrupt,i can not use "prinft" to print anything .if i use the "printf",the uart will go wrong.the following is my testing c code.any idea,helps.thanks all!! # include <stdio.h> # include <string.h># include <system.h># include "altera_avalon_uart_regs.h"# include "altera_avalon_uart.h" # include "alt_types.h" # include "sys/alt_irq.h" # include "altera_avalon_pio_regs.h" unsigned char flag=0; void Uart_send(unsigned char data) { alt_u16 status; status=IORD_ALTERA_AVALON_UART_STATUS(UART_0_BASE); while(!(status&0x0040)) status=IORD_ALTERA_AVALON_UART_STATUS(UART_0_BASE); IOWR_ALTERA_AVALON_UART_TXDATA(UART_0_BASE,data); } void Uart_send_n(unsigned char *ptr,unsigned char n) { for(;n>0;n--) { Uart_send(*ptr); ptr++; } } int Uart_receive(void) { alt_u16 status; int temp; status=IORD_ALTERA_AVALON_UART_STATUS(UART_0_BASE); while(!(status&0x0080)) status=IORD_ALTERA_AVALON_UART_STATUS(UART_0_BASE); temp=IORD_ALTERA_AVALON_UART_RXDATA(UART_0_BASE); return temp; } void Uart_ISR(void * context,alt_u32 id) { unsigned char temp; temp=IORD_ALTERA_AVALON_UART_RXDATA(UART_0_BASE); Uart_send(temp); flag=1; } void Uart_init() { IOWR_ALTERA_AVALON_UART_CONTROL(UART_0_BASE, 0x80); IOWR_ALTERA_AVALON_UART_STATUS(UART_0_BASE, 0x0); //IOWR_ALTERA_AVALON_UART_RXDATA(UART_0_BASE, 0x0); alt_irq_register(UART_0_IRQ,0,Uart_ISR} int main() { //printf("test uart");//can not use printf here,why? Uart_init(); while(1) { if(flag==1) {flag=0; //printf("uart received data");//still can not use printf,or will go wrong } } return 0; }Link Copied
0 Replies
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page