- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI everyone
i have purchased the NIOS2 evaluate board--EP1C12 from the Altera. and i program a timer interrupt routine to create a square wave based on the evaluate board's standard design. my routines is below:# include "system.h"# include "sys/alt_irq.h"# include "altera_avalon_pio_regs.h"# include "altera_avalon_timer_regs.h"# include "alt_types.h" alt_u8 x = 0x55; static void timer_interrupts(void* context, alt_u32 id) { IOWR_ALTERA_AVALON_TIMER_STATUS(SYS_CLOCK_TIMER_BASE, 0); x = x ^ 0xFF; IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, x); } int main() { alt_irq_register(SYS_CLOCK_TIMER_IRQ, 0, timer_interrupts); IOWR_ALTERA_AVALON_TIMER_PERIODL(SYS_CLOCK_TIMER_BASE, 0x1F40);// timer interrupt period is 100us IOWR_ALTERA_AVALON_TIMER_PERIODH(SYS_CLOCK_TIMER_BASE, 0x00); IOWR_ALTERA_AVALON_TIMER_CONTROL(SYS_CLOCK_TIMER_BASE, 7); while(1) { ; } } i download the routine into the evaluate board and run it, then the square wave's period is 200us as designed. when i add some float calculation in the ISR, the period changed and bacame more than designed. the ISR is below: static void timer_interrupts(void* context, alt_u32 id) { float i; IOWR_ALTERA_AVALON_TIMER_STATUS(SYS_CLOCK_TIMER_BASE, 0); x = x ^ 0xFF; for(i=0;i<100;i++); IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, x); } The period is 2.784ms!!!!!! If "float" became "alt_u8", the period is 200us as designed. static void timer_interrupts(void* context, alt_u32 id) { alt_u8 i; IOWR_ALTERA_AVALON_TIMER_STATUS(SYS_CLOCK_TIMER_BASE, 0); x = x ^ 0xFF; for(i=0;i<100;i++); IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, x); } I wonder if there can not be float calculation in the timer interrupt or the float calculation is very slow in NIOS2????Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by oceanx@Dec 8 2005, 02:34 PM i wonder if there can not be float calculation in the timer interrupt or the float calculation is very slow in nios2????
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11424)
--- quote end ---
--- Quote End --- It could be... Nios II does not have a FPU... The 1 ms period could be because the duration of the ISR is greater than the ISR period... bye Paolo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Paolo
It seems like that i must let the "main" function to do the float calculation, right? I worry about if it can be competent for the calculation or not. We must not add float calculation in the ISR? Best Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by oceanx@Dec 9 2005, 08:56 AM thanks, paolo
it seems like that i must let the "main" function to do the float calculation, right? i worry about if it can be competent for the calculation or not.
we must not add float calculation in the isr?
best regards
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11451)
--- quote end ---
--- Quote End --- Without floating point hardware, a set of software emulation libraries is used when you use float numbers in a program. These tend to be very, very slow, but they do work. If you want to speed up floating point arithmetic, there are some custom instruction examples posted in the "projects" are of this forum which may be useful. In addition, when writing interrupt handling code it is recomended in the Altera software developer's manual that interrupt service routines be as short and efficient as possible. It is far better, for example, for the interrupt routine to set a pointer or signal so that some other (non-interrupt task) can then go perform the slow calculation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by jesse@Dec 10 2005, 03:53 AM without floating point hardware, a set of software emulation libraries is used when you use float numbers in a program. these tend to be very, very slow, but they do work.
if you want to speed up floating point arithmetic, there are some custom instruction examples posted in the "projects" are of this forum which may be useful.
in addition, when writing interrupt handling code it is recomended in the altera software developer's manual that interrupt service routines be as short and efficient as possible. it is far better, for example, for the interrupt routine to set a pointer or signal so that some other (non-interrupt task) can then go perform the slow calculation.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11459)
--- quote end ---
--- Quote End --- Thanks, Jesse i will try it again. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif Best Regards
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