Hi,
I write assembly interrupts often and the main reason that I do this is for timing. I would not recommend jumping into, out of, back into and finally out of the ISR just to increment some counters. I have cut part of my ASM ISR out to show how to increment variables.
Note that TMR0CNT is a word variable declared in the basic program body. Hope this helps.Code:TOCK BCF 0x0B,2 ;CLEAR INT FLAG MOVLW 0x64 ;LOAD (PRELOAD) INTO W MOVWF 01 ;LOAD W INTO TMR0 INCFSZ _TMR0CNT,1 ;INC LOW BYTE OF COUNTER - SKIP NEXT IF IT ROLLS OVER RETURN ;LOW BYTE DIDN'T ROLL OVER SO RETURN WITHOUT INC UPPER BYTE INCF _TMR0CNT + 1,1 ;LOW BYTE ROLLED OVER SO INC HIGH BYTE RETURN ;RETURN
Regards,
Joe.




Bookmarks