Shorter interrupt latency (PIC 16F)

Thread Starter

takao21203

Joined Apr 28, 2012
3,702
Just an idea I had...

Comments?

Rich (BB code):
if(TMR0IF)
    {
    TMR0IF=0;
    v_sys_flags|=1;
    }
Rich (BB code):
 v_sys_flags|=(INTCON&TMR0IF_value);
 INTCON&=(0xff-TMR0IF_value);
Maybe won't be cutting it much but for unoptimized 16F, could be a few cycles?
 

JohnInTX

Joined Jun 26, 2012
4,787
You might find that the second one generates more code because it has to store intermediate results. Depending on the banks, the first example could be generated in as little as 4 instructions.

All you have to do to make sure is to View->Dissassembly Listing (MPLAB 8.x) or Window->Output->Dissembler Listing (MPLABX) to see what assembler code the compiler generates. It will vary by family, compiler and optimization level. XC8 w/OCG is pretty good at figuring this kind thing out. Others not so much.
 
Last edited:
Top