18m2 and setfreq command

Texy

Senior Member
Hi,
just received my latest order from Rev-Ed - only took a day from ordering on-line to my door:)
Included with the order was the complete range of the new M2 chips to play with.
I,ve got a problem with the 18M2 chip - it doesn't seem to like the setfreq command. PE goes through the
prgramming fine, but the picaxe refuses to run with any setfreq command - even setfreq m4 (which is effectively the default frequency). Here is the program (i,m trying out some 433mhz modules, the 18M2 is the TX).

Code:
#picaxe 18M2

;setfreq m8


symbol TXD = b.3


let dirsb = %11111100 ; b0,1 i/p, rest o/p   <<<<<< note % sign missing and it should be 11111100 ?????


sertxd("Start!",cr,lf)
low TXD
b5="5"
b4="4"
b3="3"
b2="2"
b1="1"
b0="0"
main:
w0=time
serout TXD,N2400_8,($AA,$AA,$AA,$AA,$AA,"ABC",b5,b4,b3,b2,b1,b0)
pause 1000
goto main
Note I,m using an AXE90 experimental breadboard and 4 x AA nihm for power which are giving out just over 5 volts.

I know the 'axe isn't running because nothing is displayed on the terminal screen, nothing is received by the RX, and my PC speaker stops buzzing every second when data is supposed to be transmitting.
Confused!

((PS the forum doesn't like percentage sign111100)) - now fixed - turn off auto parse
Texy
 
Last edited:

Texy

Senior Member
Thanks Westy - turned off auto parse and the %11111100 is now correct.
Now back to the real problem;)

Texy
 

hippy

Ex-Staff (retired)
the picaxe refuses to run with any setfreq command
By "refuses to run" do you really mean you aren't getting the outcome you expect ? Try this test program ...

#Picaxe 18M2
#Terminal 9600
SetFreq M8
Do
SerTxd( "<--- UUUU --->", CR, LF )
Pause 1000
Loop
 

Texy

Senior Member
By "refuses to run" do you really mean you aren't getting the outcome you expect ? Try this test program ...

#Picaxe 18M2
#Terminal 9600
SetFreq M8
Do
SerTxd( "<--- UUUU --->", CR, LF )
Pause 1000
Loop

"I know the 'axe isn't running because nothing is displayed on the terminal screen, nothing is received by the RX, and my PC speaker stops buzzing every second when data is supposed to be transmitting."

So I mean, refuses to run - "sertxd("Start!",cr,lf)" -this isn't being actioned. If I rem out the setfreq command, then all is well.
I will give your prog a go this evening, but I,m not hopeful.

Cheers,
Texy
 

hippy

Ex-Staff (retired)
I mean, refuses to run - "sertxd("Start!",cr,lf)" -this isn't being actioned. If I rem out the setfreq command, then all is well.
It seems to be working for me but it was necessary to add a PAUSE 2000 at the start of the program or the Terminal Display opens after the "Start!" has been sent by the PICAXE so isn't shown.
 

Texy

Senior Member
OK, but I also know the picaxe isn't running as I,m not getting the interference picked up by the PC speaker. Have there been any firmware updates for the 18m2 recently - are you running what Rev Ed are currently shipping? ( I can't tell you my revision until I get home. )
Texy
 

MartinM57

Moderator
OK, but I also know the picaxe isn't running as I,m not getting the interference picked up by the PC speaker.
I think you might need to prove "isn't running" by a means other than speaker interference ;) - like putting a sertxd after your serout to see if anything shows on the Terminal window.
...as well as noting Hippy's point that you have to put a PAUSE at the start to allow the Terminal window to open
 

westaust55

Moderator
The need for a delay before SERTXD to allow the PE terminal window to open has cropped up a few times recently and something I have commented upon ages ago myself.
Maybe worth Rev Ed adding a note under the SERTXD command in PICAXE manual 2 and even adding the line:
PAUSE 1000 ; give time for PE terminal Screen to initialise​
at the start of the example program code on the same page (V7.7 page 210)
 
Last edited:

Texy

Senior Member
Well I,ll give it a go (delay before terminal opens), but I,m still not convinced. Of course another reason why I don't think its running is that the receiver isn't getting anything (yes, I have the approriate baud rate setting applied to either 4 or 8 meg operation:)). This is what I was doing last night -
(setfreq rem'ed out)
tweak program to TX ciruit and program picaxe - speaker buzz every second, and Start! displayed on terminal window
move axe027 cable from tx to rx circuit
if not already up, bring up terminal window - observe data received over rf as program sertxd'd it
(so far so good)

moved axe027 cable back to TX circuit
un-rem'ed setfreq command, changed N1200_4 to N1200_8 and repogrammed picaxe - noted NO BUZZ on speaker, and no Start! on terminal window
moved axe027 cable back to RX circuit
brought up terminal window, no data received, even when RX repowered and Start! displayed (yes both TX and RX should display Start! on the terminal).

I,m probably doing something silly. I,ll check again tonight.
Cheers for the suggestions.
Texy
 

Technical

Technical Support
Staff member
We have identified an issue with the setfreq command on the latest 18M2 firmware (version 2.C are the only parts affected) which was only released a few days back, so only has a very small circulation at present (only sold via direct orders from techsupplies.co.uk in the last two weeks, no distributors had this firmware version).

Fortunately it is easily fixed with a software update, so please download and install the 5.4.1 patch from the PICAXE software pages (see 'free software' link at the top of this page). This will then allow you to add a '#picaxe 18m2_c' directive to the top of your program and the compiler will then fix the issue for you so the commands work as expected.

We will be updating the 18M2 firmware to 2.D to fix the issue. Very sorry for any inconvenience caused, and thanks for bringing it to our attention.

(Anyone with 18M2 v2.C who wants it changed to 2.D are welcome to send it back for free reprogramming).
 
Last edited:

alhoop

Member
#Picaxe 18M2
#Terminal 9600
SetFreq M8
Do
SerTxd( "<--- UUUU --->", CR, LF )
Pause 1000
Loop

This program works fine until I add another task at which time I get the following error

'Error: setfreq not allowed in multi task program'

PE v5.4.0 and Picaxe 18m v2.b

Thanks for any help.
Al
 

hippy

Ex-Staff (retired)
This program works fine until I add another task at which time I get the following error

'Error: setfreq not allowed in multi task program'
That would be correct; when multi-tasking it's not possible to use the SETFREQ command. This is noted at the bottom of page 221 in Manual 2.
 

westaust55

Moderator
In 'multi-task' the clock speed is automatically set to 16 MHz as per the information/links provided.

Try changing
#Terminal 9600
to
#Terminal 19200
 

Technical

Technical Support
Staff member
In multi task mode commands such as serout/sertxd etc. 'appear' to work at 4MHz (even though the internal clock does technically run at 16MHz - the theory behind this is to allow (very approximately) 4x4MHz tasks at the same time).

The original program will work fine once you take the the setfreq command out and set #terminal to 4800
 

alhoop

Member
Thanks for all the helpful answers. Once again I asked before looking and did not read the manual. I'm using sertxd to feed data to a Speakjet on a station stop for a model railroad. I used the 18M2 because of the memory needed for all the data. I wanted to use the multi-tasking because I didn't think there would be enough time from my next to last sensor to output all the data, but using gosubs works fine. I wanted to send the data at 9600, so instead of multi-tasking I used the gosubs and setfreq M8. I did find that the chip did seem to only work at 4Mhz for sertxd.
Al
 
Last edited:

westaust55

Moderator
In multi task mode commands such as serout/sertxd etc. 'appear' to work at 4MHz (even though the internal clock does technically run at 16MHz - the theory behind this is to allow (very approximately) 4x4MHz tasks at the same time).

The original program will work fine once you take the the setfreq command out and set #terminal to 4800
Can this please be added into the PICAXE manuals at the next revision.

For clarification (against future questions), since the above mentions 4 tasks operating at approx 4 MHz each,
is this the same nominal speed for program processing and SERTXD for those M2 parts which permit up to 8 parallel tasks?
 

hippy

Ex-Staff (retired)
Manual update request noted.

On operating speed - The chip operates at 16MHz when multi-tasking on all M2's, but from the PICAXE programmer's perspective the PICAXE code should be written as if the commands are executing at 4MHz; eg PAUSE 1000 will delay 1000ms, SERTXD will output at N4800.

This means that a program with PAUSE's and SERTXD's etc will operate in the same way, whether single-task or multi-tasking, and applies no matter how many tasks are used.
 
Top