I was going with the code below to get more interrupts / sec
it looked fine on the scope but when I actually measured the
timings they were getting gradually more off the lower the
bit value interrupt.
Probably due to the time I reside in the interrupt before setting the TMR0 registers
stays has a greater influence on the smaller periods.
I guess I will have to use the CCP compare function after all.
I didnt want to do it to be able to use my code on an 16F pic as well
where I dont have an TMR3 , so another lesson Learned.
Code:
asm INCF _BAMbit+0, 1 //
asm MOVLW 7 //
asm ANDWF _BAMbit+0, 1 // BAMbit = ( BAMbit+1 ) & 7
asm BZ LBL00 // if(Bambit==0) BamH= 0b11111110;
asm RLCF _BamH // BamH<<=1;
asm GOTO LBL01 // Were done for now
asm LBL00:
asm MOVLW 0b11111110 //
asm MOVWF _BamH // BamH= 0b11111110;
asm LBL01:
BamL=BamH; // Make a temporary copy
asm SWAPF _BamL // swap nibbles
BamL |=0xF0; // Set Hi nibble
asm MOVFF _BamL,TMR0H // Set TMR0H
asm MOVFF _BamH,_BamL // swap nibbles
asm SWAPF _BamL // swap nibbles
BamL &=0xF0; // clear low nibble
BamL |=0x02; // Add 2 for adjust TMR0 Write
asm MOVFF _BamL,TMR0L // Write new timer value