- Name:
- calibfreq
- Syntax:
-
CALIBFREQ {-} factor
factor - is a constant/variable containing the value -31 to 31
- Description:
-
Calibrate the microcontrollers internal resonator. 0 is the default factory setting.
PICAXE chips have an internal resonator that can be set to different operating speeds via the setfreq command. On these chips it is also possible to 'calibrate' this frequency. This is an advanced feature not normally required by most users, as all chips are factory calibrated to the most accurate setting.
Generally the only use for calibfreq is to slightly adjust the frequency for serial transactions with third party devices. A larger positive value increases speed, a larger negative value decreases speed. Try the values -4 to + 4 first, before going to a higher or lower value.
Use this command with extreme care. It can alter the frequency of the PICAXE chip beyond the serial download tolerance - in this case you will need to perform a hard-reset in order to carry out a new download. The calibfreq is actually a pseudo command that performs a poke command on the microcontrollers OSCTUNE register.
When the value is 0 to 31 the equivalent BASIC code is
pokesfr OSCTUNE, factor pause 2 When the factor is -31 to -1 the equivalent BASIC code is
let b12 = 64 - factor pokesfr OSCTUNE, b12 pause 2 Note that in this case variable b12 is used, and hence corrupted, by the command. This is necessary to pokesfr the OSCTUNE register with the correct value.
- Applies To:
- All (except 08, 18, 18A, 28, 28A, 28X, 40X)
- See Also:
- Related Create:
Increase the speed of the internal resonator slightly
This shows how to increase the speed of the internal resonator slightly
- Code Example:
-
calibfreq 2
Copy Code Submit an Example
Decrease the speed of the internal resonator slightly
This shows how to decrease the speed of the internal resonator slightly
- Code Example:
-
calibfreq -2
Copy Code Submit an Example
Submit Your Own Code!
You must be logged in to submit code examples. Login now.