- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all
I cant find example for uart with HAL http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif I have two RS232 uarts (uart232,uart0) 1'st i connect to stdin stdout and use it for debuging (uart232) 2'nd i try to make workable (uart0) My goal is : create interrupt for uart0 which execute when uart0 recive data and in interrupt function i want transsmit received data from uart0 to uart232 data->uart0->uart232 I can't understand why that code hang's void isr_uart0(void* context, alt_u32 id) // uart0 interrupt handler { alt_u32 status; // status = IORD_ALTERA_AVALON_UART_STATUS(base); printf("%s",IORD_ALTERA_AVALON_UART_RXDATA(UART0_BASE));//read data from uart0 and write to uart232 } void ALEX_UART_TRY() //uart routines (initialization , irq register ) { void *puart0 = (void*) UART0_BASE; // set pointer to uart0 alt_u32 divisor = (ALT_CPU_FREQ/115200)-1; // calculate divisor IOWR_ALTERA_AVALON_UART_DIVISOR(UART0_BASE, divisor); // assign bbrate IOWR_ALTERA_AVALON_UART_CONTROL(UART0_BASE, // enable interrupt ALTERA_AVALON_UART_CONTROL_RRDY_MSK // Enable interrupt for a read ready ); alt_irq_register(UART0_IRQ, puart0, isr_uart0); //register irq (nios2 hangs after that ) char* msg = "hello world"; // test uart0 by sending "Hello wold" (it work fine ) FILE* fp; fp = fopen (UART0_NAME, "w"); if (fp) { fprintf(fp, "%s",msg); fclose(fp); } } void main() { ALEX_UART_TRY(); }Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure what you're trying to do here, but it looks more complex than I'd expect.
You could just open /dev/uart232 and read from it, writing to /dev/uart1 when there is data available. But if you want to do this from interrupts then you need to stop the HAL from attaching its drivers to the UARTS you are using. I suggest you stop at alt_main() and step through that function and through alt_sys_init.c to see what's going on. There's a tickbox in the launch configuration to make it stop at alt_main. To replace the HAL's drivers you should copy the appropriate files from the altera_avalon_uart directory into your system project and edit them there. The build system will use your copies instead of the shipped ones and you can edit as much as you want.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May be, you should think about the printf-statement in your isr. Is it possible that this blocks the system? Take a look at "NIOS II Software Developmer's Handbook" page 6-7 / 6-8
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