- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Could somebody tell me that the following testisr.c program is correct. The ISR “irq_handler” is installed by “nr_installuserisr” procedure. The parametr “context” is set to pointer to &stab[0] record, which contains four semaphore variables. The “->sema” variable, initially set to 0, is tested in main() subroutine until it is set to 1 in “irq_handler()” after hardware interrupt occurred. Second test is performed on “->semb” variable, which is never touched in ISR. I’m not sure that is correct way to handle critical region in Nios 3.20 environment independently on compiler options. Could you tell me which registers are store on stack when the ISR is invoked. Do I have to be aware of any registers when I use record variables set up by pointer (->) expressions to send data between ISR and main program? There is the Nios testisr.c program. I use Nios 3.20 SDK under Windows 2000. Compilation is performed by invoking nios-build –O2 testisr.c. Regards Chris typedef struct{ int sema; int semb ; char semc; short semd; }s_st; s_st stab[2]; int main(){ s_st *pst; pst = &stab[0]; pst->sema =0; pst->semb =0; pst->semc =0; pst->semd =0; nr_installuserisr(IRQ_num,irq_handler,(int)&stab[0]); //we are waiting for irq... laba: if(pst->sema == 0) goto laba; if(pst->sema != 1) printf("Something wrong with Nios ISR?"); //...at isr semaphore was changed // and next we are in infinite loop labb: if(pst->semb == 0) goto labb; printf("Something wrong with Nios ISR?\n"); return 0; } //isr void irq_handler(int context){ s_st *pst; pst = (s_st *)context; pst->sema = 1; }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