- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello guys, I got problems with my interrupt routines. One routine is for uart whitch means if a character comes in it'll be stored in a buffer array, the other one is for simple timer ticks.
I wrote following for enabling the interrupts: alt_irq_enable (SYS_TIMER1_IRQ); alt_irq_enable (UART_IRQ); Next, I wrote the request routines: alt_irq_register (SYS_TIMER1_IRQ, pWORKINGVAR, ServiceRoutineTIMER); alt_irq_register (UART_IRQ, pWORKINGVAR, ServiceRoutineUART); When I debug my code I be able to see the STATUS register whitch holds the value 0x1 (Interrupts enabled) and the IENABLE register whitch holds the value 0x6 (2 for uart and 1 for timer). I think both are corrcet... Can you check my code about errors, do I need additional code for enabling interrupts ??? How can I proof that an interrupt occured ??? (register ect.) Thank's for helping... MaestroLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You don't need additional code to enable interrupt, alt_irq_register() routine enables the requested interrupt if ISR pointer is not NULL. You can check for IPENDING register in Nios II CPU for any pending interrupts. Hope this help. :)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Iftan, thank's for your reply.
My problem is very confuse. My ISR for the timer interrupt works perfect. I checked also the IPENDING register, if there is an incoming timer interrupt I can see 0x02 (for the timer interrupt flag), after that, the timer ISR enters. But my uart ISR doesn't work. I use HyperTerminal for communication. I checked the hardware with a simple polling routine. Every time I press an key the routine returns the character to HyperTerminal. Works fine but is laborious. I dont't see the changing of the IPENDING register, either. Could it be, that a hardware or software part blocks the uart interrupt request ???- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
If you enable reduced device driver or small driver, it uses the polling instead of interrupt. That why you can't see any change for IPENDING. :)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh oh, I have to mark "reduced device driver" because I haven't an external RAM therefore I currently debug from ONCHIP RAM. It isn't large enough to fit my design with large device drivers. Is there a possibility to circumvent this problem. I must say, two days ago the uart ISR works... after Re-compilation of my Quartus project and downloading to my system the ISR failed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
by the way, you must use interrupt mode in UART?
If "reduced device driver" or "small driver" is enabled, it uses polling mode in UART driver. Thus, it no call to alt_irq_register(). There are few solutions for this: - Increase your on-chip memory size so that can set "reduced device driver" or "small driver" to false (but you need to check the HW spec). - Use external memory ("reduced device driver" = false) - "reduced device driver" = true, modify UART driver to use interrupt even if "reduced device driver" is enabled (I never try this before and not sure it can work or not and I'm not sure the code size can fit to your on-chip memory or not after this change). Good luck!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have one question about UART. If I use reduced device driver I will be unable to write my own ISR to use UART ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, are you using your own UART driver or Altera provided UART driver?
If "reduced device driver" or "small driver" is enabled, it doesn't use the ISR routine altera_avalon_uart_irq(). Instead, it will use the polling mode. For example, when you try to read or write something to UART, it will block the program (while loop), until it can send or receive any data from UART. You can try to read the source code for altera_avalon_uart_write() and altera_avalon_uart_read() routines under the# if defined(ALT_USE_SMALL_DRIVERS) || defined(ALTERA_AVALON_UART_SMALL). You can understand more.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see. So, I have second question. Can I replace original driver with my own, which is using interrupts ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you can. But you need to manage the ISR yourself, i.e registering ISR routine.
Anyway, you can disable "reduced device driver" feature if you would like to use interrupt mode.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For more information about developing device driver, please see Chapter 7:
http://www.altera.com/literature/hb/nios2/n2sw_nii52005.pdf- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page