Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20680 Discussions

enable/disable interrupt

Altera_Forum
Honored Contributor II
1,405 Views

Hi, 

 

I am porting a small kernel from avr to nios2 using a DE2 board. I have tried to modify the enable and disable interrupt macro like the follow: 

 

# define DISABLE_INTERRUPTS {  

asm volatile (  

"addi r27, r27, -4 \n\t"  

"stw r3, 0(r27) \n\t"  

"addi r27, r27, -4 \n\t"  

"stw r2, 0(r27) \n\t"  

"movhi r2, 0xFF00 \n\t"  

"subi r2, r2, 2 \n\t"  

"rdctl r3, ctl0 \n\t"  

"and r3, r3, r2 \n\t"  

"wrctl ctl0, r3 \n\t"  

"ldw r2, 0(r27) \n\t"  

"addi r27, r27, 4 \n\t"  

"ldw r3, 0(r27) \n\t"  

"addi r27, r27, 4 " );  

 

# define ENABLE_INTERRUPTS {  

asm volatile (  

"addi r27, r27, -4 \n\t"  

"stw r3, 0(r27) \n\t"  

"rdctl r3, ctl0 \n\t"  

"ori r3, r3, 1 \n\t"  

"wrctl ctl0, r3 \n\t"  

"ldw r3, 0(r27) \n\t"  

"addi r27, r27, 4 " );  

 

When I try to debug using the hardware, the status register can not be correctly set. But when I use the instruction set simulator, it works fine. 

Can someone give me some hint. 

 

with regards, 

Wei
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
512 Views

Why don't you use altera's library irq enable and disable?

0 Kudos
Altera_Forum
Honored Contributor II
512 Views

Hi aprado, 

 

--- Quote Start ---  

Why don't you use altera's library irq enable and disable? 

--- Quote End ---  

 

I have looked into the provided one. 

The alt_irq_enable_all need a context, which force me the modify other kernel code.
0 Kudos
Altera_Forum
Honored Contributor II
512 Views

you can pass null as the context i think

0 Kudos
Altera_Forum
Honored Contributor II
512 Views

 

--- Quote Start ---  

you can pass null as the context i think 

--- Quote End ---  

 

I will try that.
0 Kudos
Altera_Forum
Honored Contributor II
512 Views

Context is useful when calling irq enable all to restore interrupt conditions present before calling irq disable all!

0 Kudos
Reply