Altera_Forum
Honored Contributor
14 years agoenable/disable interrupt
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