> Just wondering about the accuracy of the above interval.
The ISRTimer module is just a general purpose module that allows you to have multiple 16 bit timers. The timeout math is correct, but the end result will be skewed by the time taken to process the interrupt iseft. In short, it is not (or meant to be) a precision timer. For example, you might want to flash and LED with one timer and scan a keypad with another whilst at the same time wating for serial input. In this example, the ISRTimer library would be ideal (TimB posted a module on the wiki which uses the ISRTimer module to scan a keypad and it works really well). However, much of the code is still valid if you want to create a precision timer.
> When setting, for instance, TMR1 = -20000, does the compiler
> interpret this as 65536 - 20000
Ideally, you need to load TMR1 with a positive word value (for example, 65536 - 20000 = 45536). If you try and load a negative constant value, you get a 'constant expression violates subrage bounds' error, because TMR1 is a word.
You can typecast of course. For example,
which will force the compiler to stuff $B1E0 (45536) into TMR1
> loading TMR1H first, and then TMR1L next even though the
> form TMR1L.AsWord is used
Yes, high byte first. In the above example, the ASM generated is
Code: Select all
MOVLW 177
MOVWF _TMR1L#M0_U16H,0 <-- HIGH BYTE
MOVLW 224
MOVWF _TMR1L#M0_U16,0