PropBASIC - PULSOUT - low clock speed
phatallica
Posts: 64
Note of caution for PULSOUT with PropBASIC ...
The following code does not work with 5MHz crystal and PLL1X, but does work with PLL2X or higher:
The duration of the pulse does not seem to matter, either, as I tried several orders of magnitude. Using PULSOUT with 5MHz just seems to hang-up the code, with the pin HIGH.
I don't see many folks posting code at such low frequency, so maybe I am the only one who has ever noticed this?
Side note - PropBASIC Syntax Guide, Version 0.13, page 8 ... the following is shown to demonstrate syntax:
It seems that Timeout never actually made it into the feature set of PropBASIC. I don't have a practical need for it, but for some reason once I know that I can't have it, I suddenly want it.
The following code does not work with 5MHz crystal and PLL1X, but does work with PLL2X or higher:
' Use: HCSR04_inch ' --- Pulses TRIG pin for 10us to initiate transmission burst of 40kHz ' --- Reads ECHO pulse to calculate distance '{$IFUSED HCSR04_inch} FUNC HCSR04_inch PULSOUT TRIG,10 ' initiation pulse PULSIN ECHO, 1, __param1 ' measure HIGH time; cannot set timeout, so must wait __param1 = __param1 / 148 ' convert to integer inches RETURN ' returning param1 is implied ENDFUNC '{$ENDIF}
The duration of the pulse does not seem to matter, either, as I tried several orders of magnitude. Using PULSOUT with 5MHz just seems to hang-up the code, with the pin HIGH.
I don't see many folks posting code at such low frequency, so maybe I am the only one who has ever noticed this?
Side note - PropBASIC Syntax Guide, Version 0.13, page 8 ... the following is shown to demonstrate syntax:
PULSIN Pin, State, Variable {, Timeout}
In this case, the parameter for Timeout is optional.It seems that Timeout never actually made it into the feature set of PropBASIC. I don't have a practical need for it, but for some reason once I know that I can't have it, I suddenly want it.
Comments
Bean
The code doesn't actually hang, but it will stop until the hardware counter rolls-over for each microsecond (that could be a LONG time).
Thanks again for pointing it out and I'll have it fixed in the next release of PropBasic.
Bean
Thanks, Bean.