Its a bit messy - but it works ! Tomorrow we optimise !
This is a snippet that shows how to change the Prescaler value from within the interrupt routinue using Instant Interrupts.
bill.Code:DEFINE OSC 20 rs_led var portb.7 led var portc.4 loops var byte ' count round the loop to load prescaler INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR0_INT, _doBAM, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM OPTION_REG = %11010000 'Set TMR0 Prescaler to 2, leave RBPU alone TMR0 = 158 ' preload with 158 to give 21uS interrupts loops = 0 ' interrupt routinue doBAM: toggle rs_led if loops > 6 then loops = 0 else loops = loops+1 endif option_reg.0 = loops.0 option_reg.1 = loops.1 option_reg.2 = loops.2 TMR0 = 158 @ INT_RETURN




Bookmarks