- Name:
-
setfreq
- Syntax:
-
SETFREQ freq
Freq - is the keyword that selects the appropriate frequency
| All M2 parts |
internal k31, k250, k500, m1, m2, m4, m8, m16, m32 |
|
| 20X2 |
internal k31, k250, k500, m1, m2, m4, m8, m16, m32 ,m64 |
|
| 28X2, 40X2 |
internal k31, k250, k500, m1, m2, m4, m8, m16 |
external em16, em32, em40, em64 |
Superseded older parts:
| 08M, 14M, 20M |
internal m4, m8 |
|
| 18A, 18M, 18X |
internal m4, m8 |
|
| 28X1, 40X1 |
internal k31, k125, k250, k500, m1, m2, m4, m8 |
external em4, em8, em10, em16, em20 |
| 28X2-5V, 40X2-5V |
internal k31, k250, k500, m1, m2, m4, m8 |
external em16, em32, em40 |
| 28X2-3V, 40X2-3V |
internal k31, k250, k500, m1, m2, m4, m8, m16 |
external em16, em32, em40, em64 |
| where |
k31 |
= 31kHz internal resonator |
| |
m4 |
= 4MHz internal resonator etc. |
| |
em16 |
= 16MHz external resonator etc. |
- Description:
-
Set the internal clock frequency for microcontrollers with internal resonator to 8MHz (m8) or some other value.
The default value on X2 parts is 8MHz internal. The default value on all other parts is 4MHz internal.
The setfreq command can be used to change the speed of operation of the microcontroller from 4MHz to 8MHz (or some other value). However note that this speed increase affects many commands, by, for instance, changing their properties (e.g. all pause commands are half the length at 8MHz).
Note that the X2 parts have an internal x4 PLL inside the chip. This multiplies the external resonator speed by 4. Therefore the external resonator value to be used is 1/4 of the desired final speed (ie in mode em40 use an external 10MHz resonator, for em16 use a 4MHz resonator).
The change occurs immediately. All programs default to m4 (4MHz) if a setfreq command is not used (default is increased to m8, 8MHz on X2 parts).
Note that the Programming Editor only supports certain frequencies for new program downloads. If your chip is running at a different frequency the M2, X1 and X2 parts will automatically switch back to internal 4MHz /8MHz default speed to complete the download.
On M2 'multi-tasking' programs the setfreq command may not be used, as the oscillator speed is under control of the PICAXE firmware for task processing. The internal resonator frequencies are factory preset to the most accurate settings. However advanced users may use the calibfreq command to adjust these factory preset settings. Some commands such as readtemp will only work at 4MHz. In these cases change back to 4MHz temporarily to operate these commands (on M2, X1 and X2 parts this is automatic). Note that a temporary change in frequency (either programmed or automatic) will have a direct effect on background frequency dependant tasks such as pwmout / hpwm.