Forum Discussion
Altera_Forum
Honored Contributor
22 years agoNios Semaphore?
I need a good semaphore to make a fifo IRQ safe. On the PC it's easy with the assembly instruction BTS which Bit Tests and Sets. So you can try to set a bit and know if you did it in a single c...
Altera_Forum
Honored Contributor
22 years agoSCS,
I tried that first, but was having issues with ISR's disabling interrupts. Anyway, I revisited disabling interrupts and tested exhaustively and seems fine now. So Thanks! Here are some NiosI macros if anyone is interested. BTW, is there a doc with all the asm syntax? I'd like to assign stat as the return value. # define get_status_reg(stat) { unsigned int status; asm("rdctl %0" : "=r" (status)); stat = status; } # define disable_interrupts() asm("PFX 8" ); asm("WRCTL %g0"); # define enable_interrupts() asm("PFX 9" ); asm("WRCTL %g0"); # define interrupts_enabled(stat) { unsigned int status; asm("rdctl %0" : "=r" (status)); stat = status & 0x8000; }