SPE035

benbaker7

Active member
Hi Foks. I'm using an SPE035 cheap Chinese equivalent module in conjunction with an 08M2 on a breadboard, with the pins/wiring adjusted appropriately from the 14M2 samples.
.
In the sample programs, the command MDEFAULT is used to restore the freq to 4mHz. Using PE5, the command gives me a syntax error.

The updated setfreq detail from the PICAXE site does not seem to mention any reason for this, where MDEFAULT is specifically referenced in para 2 of the description.
Upon switching to PE6, the command works perfectly, so I can only reason that MDEFAULT is specific to PE6 and its updated (over PE5) processing capabilities.

So I use setfreq M4 with PE5 and all is OK.

I would be interested to hear if my reasoning is correct, or whether there is a method to use MDEFAULT with PE5.

For what it's worth, I'm comfortable with PE5 and for the level of my programming, it's more than adequate. I find PE6 to be somewhat arcane and its advanced features, although no doubt suited to more skilled users, difficult to use, apart from the inordinately long loading time over PE5.

Ben Baker
 

AllyCat

Senior Member
Hi Ben,

Yes, I must admit that I also "prefer" PE5 for its speed and clarity in some applications, but one must accept that it has some unfixed (and now unfixable) bugs, and a number of "missing" functions, particularly concerning the preprocessor/directives (# commands). Other advantages / necessities of PE6 are in simulating RANDOM, much better features in the "Terminal" (although it seems to crash / hang rather more frequently) and perhaps many others that I can't recall at the moment.

Personally, I always try to write my programs to be "compatible" with PE5, and AXEPad to help with Linux / Apple applications, but then test with PE6 before reporting any "bugs". ;)

Cheers, Alan.
 

inglewoodpete

Senior Member
MDEFAULT is not a command or parameter but a pseudo parameter meaning "insert the default clock frequency parameter for the type of chip you are using". So for M2-series chips use M4 and for X2 chips, use M8. Either of which will work with PE5 or PE6.

Before you say it, I will agree with you that it is not the best piece of documentation that I have seen.
 

benbaker7

Active member
Thanks fellers. That clarifies things in my mind. So therefore MDEFAULT works similarly to WAIT in that the manual tells me the latter is a pseudo command recognised by the compiler as ' PAUSE 1000', but MDEFAULT is a newer iteration not recognisable by the old PE5. I suppose it would have been fixed in an update to PE5, which I guess will now never happen. Oh well, more traps for young (old) players.

Ben Baker
 

inglewoodpete

Senior Member
Thanks fellers. That clarifies things in my mind. So therefore MDEFAULT works similarly to WAIT in that the manual tells me the latter is a pseudo command recognised by the compiler as ' PAUSE 1000', but MDEFAULT is a newer iteration not recognisable by the old PE5. I suppose it would have been fixed in an update to PE5, which I guess will now never happen. Oh well, more traps for young (old) players.

Ben Baker
No, MDEFAULT is not a genuine parameter for either Programming Editor. It is more like an instruction to the person using the code to manually insert their PICAXE's default clock speed. Perhaps it would be better expressed as M<default>.

Edit: I turns out I'm not correct. I was using what I thought was the latest documentation that came with PE Version 6.1.0.0, which must be out of date.
 
Last edited:

AllyCat

Senior Member
Hi,

Actually, MDEFAULT is a "number" (byte), or to be precise a "Pre-defined System Constant", in a similar manner that "time" (M2s only) is a Pre-defined system variable. The PICaxe system/compiler uses a lot of them, some quite surprising (and sometimes quite useful), but they cause a problem of where to reference (or index) them (for example "time" used to be found only in the LET description). You can prove the point by simply "Printing" the number, for example in the Simulator or to the Terminal, with a SERTXD(#MDEFAULT).

Sometimes the "numbers" are a simple index (e.g. 0, 1, 2, etc.) and sometimes formed from "flags" which will be sent directly to a "Special Function Register" (SFR). MDEFAULT appears to be one of the latter because it takes the values of 98 or 106 (decimal); it may be instructive to examine all the m1 , m2 , m4 , m8 , ... k250 , etc. (setfreq) values for M2 and X2 processors. Or if you're more ambitious, you could write a small subroutine or Macro (PE6) to display the values (typically in a word, w0 or w1) in decimal (denary), Hex, and binary, etc..

They form much of the content of the "Reserved Words" Appendix 2, in Manual 2, which fills more than a page of text! However, some still appear to be missing (including MDEFAULT), so you may only discover them when the compiler throws a Syntax Error for a "Doubly-defined" constant or variable, when you try to declare one.

Quite a few may be "surprising" to the uninitiated, for example all the port.pins, e.g. c.0 , c.1 , ... , etc. resolve to an index number, and all the "Baud" rates are a "hybrid" index number, with a polarity flag added. Conversely, there are a few "constants" that might be expected (and desired) to resolve to a numerical value, but do NOT, for example PWMDIV4 and IT_5V0 (readinternaltemp), etc..

Cheers, Alan.
 

Technical

Technical Support
Staff member
MDEFAULT is a constant, exactly the same format as M4 or M8 (and equivalent to either depending on the chip you are using). It's included in the latest compilers within PE6, PE5 has not been updated for many years as no longer supported. However if you were to manually copy the latest compilers out of PE6 back into PE5....
 
Top