Is it possible to create a Conditional Compilation for the Pulsout function? This would surely simplify running the BS2 code for the BoeBot, etc on a BS2sx chip. Just a thoght...
Sure. Along with the Baud constants, just add an adjustment factor. For the BS2 models, the unit is either 2us or 0.8us. To get the PULSOUT argument, you'd need to divide the time in us by either 2 or 8/10. Alternatively you could multiply by 2/4 (1/2) or 5/4 (10/8). In the various condition compilation choices, you'd define a constant "adjFactor" as either 2 (for 2us) or 5 (for 0.8us) and make each PULSOUT like "PULSOUT <pin>,(<time us>*adjFactor)>>2".
You could use the conditional compilation directives right around the PULSOUT statement(s), but you'd end up with a very very difficult to read, but otherwise correct and efficient version.
Comments
You could use the conditional compilation directives right around the PULSOUT statement(s), but you'd end up with a very very difficult to read, but otherwise correct and efficient version.
myPin PIN 13
then you'd add either
adjFactor CON 2 ' PULSOUT unit is 2us
or
adjFactor CON 5 ' PULSOUT unit is 0.8us
to the various groups of conditional declarations.
If you want to produce a 1.5ms pulse, you'd put
PULSOUT myPin, (1500 * adjFactor) >> 2