Which instructions are affected by reduced oscillator speed?

Tvmender

Active member
Hi All

Please bare with me as I am still relatively new to PICAXE.

Can anyone tell me which of the instructions are affected by a reduced oscillator speed automatically by the PICAXE? I assume that all PICAXE part numbers will reduce the speed to execute the following?

Irin
Irout
SPE033 communication
LCD serial communication using the AXE131 interface board

Does the oscillator return to the previous speed automatically once the instruction is completed?

Can I use these instructions in one single program i.e. receive infra red then jump to output serial data for the SPE033 once the Irin routine is complete? I am aware of the loop in which the PICAXE waits for IR unless a timeout is triggered.


Thanks!
 

AllyCat

Senior Member
Hi,

Sorry, I need to answer your question with more questions, in particular: "Why Does it Matter to You (or your program)?" and "Why do you consider it necessary to increase the clock frequency in the first place?". There are of course "good" answers to all these questions (perhaps concerning PWM, Servos or the "time" variable), but you really are "Opening a Can Of Worms". Also you can't generalise that "all" PICaxe parts will behave in the same way (particularly between M2 and X2).

IMHO you should check the On-Line Command Syntax before you use them, but I believe that the commands which do reduce the clock frequency are related to InfraRed, Radio (RFIN/OUT), Keyboard (KBIN/OUT) and perhaps others. They should all restore the previous clock frequency after execution and you should be able to use them all in the same program. Then there are other commands which "only" work (correctly) at 4 MHz, but don't change the clock frequency, for example Ultrasonics and (arguably) Tune/Sound and even Pause/Wait, etc..

I'm not aware of the SPE033 or AXE131 doing this, but there is a whole class of particularly "Serial Communications" commands that cannot be made to "Run Faster" by their nature. This is usually handled by the "Underscore suffix parameters" (e.g. N9600_16 ) in Serial and I2C commands, etc.. Then there are the completely "blocking" Input commands (i.e. halting the program flow until an input is received) such as SERIN, SERRXD, RFIN, KBIN, and maybe others.

Cheers, Alan.
 

hippy

Technical Support
Staff member
I assume that all PICAXE part numbers will reduce the speed to execute the following?

Irin
Irout
SPE033 communication
LCD serial communication using the AXE131 interface board

Does the oscillator return to the previous speed automatically once the instruction is completed?
There are generally two groups of commands, those which drop the execution speed for the command so it will always operate as required, and will return the execution speed to what it was before the command, and those which simply run faster or slower when the execution is not at the default speed.

IRIN and IROUT are in the former group, drop to 4MHz while executing then return to whatever the execution speed was.

SERIN and SEROUT commands, used for SPE033, LCD and serial interfacing are in the second group. That is, if you specify say N2400 in a SEROUT command for an 08M2 it will output at 2400 baud when run at 4MHz, but will output at 4800 baud when run at 8MHz.

To allow the baud rate to be more easily specified for the execution speed there are the named constants with suffixes; N2400_4, N4800_8, N9600_16 all have the same value, would output 2400 baud when run at 4MHz, but output those other baud rates when running at their suffixed speed.

Can I use these instructions in one single program i.e. receive infra red then jump to output serial data for the SPE033 once the Irin routine is complete? I am aware of the loop in which the PICAXE waits for IR unless a timeout is triggered.
Yes. In most cases there won't be a problem; just write the code you want, use IRIN when you need to read IR input, use SEROUT with the baud rate suitable for your execution speed to control the SPE033, and it will behave how you expected and desired.
 
Top