[PicForth] Compile time questions
J.C. Wren
jcwren at jcwren.com
Wed Jun 23 23:26:27 CEST 2004
I'm playing with the timer 1 registers, and can't figure out how to
express something correctly. Let's say you're running at 19.6608Mhz.
At that speed, there are 49152 ($c000) counts in a 10 millisecond
interval. The counter counts up, so you load the TMR1H and TMR1L
registers with the negated value, which would be 16384 ($4000). I'd
like to put this as a constant at the top, so '$c000 constant
tmr1Reload'. In the handler code, I want to change modes (correct term,
please?) so that rather than taking the constant and AND'ing it with $ff
or / 8 at run time, it's done at compile time. I know (I think) this
needs to be handled outside of the PicForth compilation because PicForth
doesn't understand 16 bit values of any kind.
The other question is sometimes I want to be in decimal mode while
I'm compiling. In "normal" Forth, you use 'decimal', and it's done.
I've tried 'host decimal target', but that's not changing the mode. I
think I've been through all the examples, and I can't find anything that
approximates what I'm trying to do in either case (or I'm not
recognizing it as such).
Any ideas?
: timerReload
[ tmr1Reload $ff and ] tmr1l !
[ tmr1Reload $100 / ] tmr1h !
;
--jc
More information about the PicForth
mailing list