Shorter interrupt latency (PIC 16F)

Discussion in 'Embedded Systems and Microcontrollers' started by takao21203, Feb 17, 2014.

  1. takao21203

    Thread Starter Distinguished Member

    Apr 28, 2012
    3,577
    463
    Just an idea I had...

    Comments?

    Code ( (Unknown Language)):
    1. if(TMR0IF)
    2.     {
    3.     TMR0IF=0;
    4.     v_sys_flags|=1;
    5.     }
    Code ( (Unknown Language)):
    1.  
    2.  v_sys_flags|=(INTCON&TMR0IF_value);
    3.  INTCON&=(0xff-TMR0IF_value);
    4.  
    Maybe won't be cutting it much but for unoptimized 16F, could be a few cycles?
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,022
    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: Feb 17, 2014
Loading...