08M vs 08M2 and the PEEK/POKE command

IronJungle

Senior Member
General question before I go down the wrong debug path....

I have a program that was written for the 08M. I pushed that 08M program into a 08M2 and something doesn't work quite right. Based on almost nothing, I suspect the PEEK/POKE statements.

Are the PEEK and POKE statements in a 08M transferable to the 08M2 without modification or are there factors I should consider?

Thanks
 

westaust55

Moderator
There are some variables between the M and M2 parts with respect to PEEK and POKE fuctions.

In the M parts, the PEEK and POKE commands worked with the first 256 register locations which included SRF registers and RAM memory locations.


For the M2 parts this functionality has been split over the PEEK, POKE, PEEKSRF and POKESRF commands.

I suggest that you read the relevant sections of the PICAXE manual 2 to appreciate the changes.
 

IronJungle

Senior Member
Great. Thanks. I wanted to check that before I considered other issues. I will study up and see if I can make sense of things.

Off the Manual 2....
Thanks again.
 

hippy

Ex-Staff (retired)
Also check out the M2 product information sheet ...

http://www.picaxe.com/docs/picaxem2.pdf

The 08M2 has 128 bytes of RAM accessed via PEEK, POKE and 'bptr'. The first 28 bytes of that RAM are also the variables 'b0' to 'b27' ( and 'w0' to 'w13' ).

The RAM within SFR on the older PICAXE was at $50-$7F ( and for some $C0-$EF or $C0-$FF ) so the locations used with PEEK and POKE may have to be adjusted when moving to M2 chips but will often fall within RAM areas not used as variables so not be a problem.
 

IronJungle

Senior Member
OK. Thanks and I moving forward (I think)

The original 08M program POKE/PEEKs are starting at location $50 and increment from there. After reading the manuals I understand now that $50-$7E are GP memory registers on the 08M.

Now moving to the 08M2 I *think* I understand the GP memory registers to start at location 28.

So... (and I will test this tonight, don't have my dev board with me) I would think that if I change the start location from $50 (on the 08M program) to 28 (on the 08M2 program) I will be okay.
Since I am using a WORD variable, I need to increment by 2 (28 + 2 = location 30) to store the next value if needed.

Am I seeing this right so far?

Thanks again all.
 

hippy

Ex-Staff (retired)
So... I would think that if I change the start location from $50 (on the 08M program) to 28 (on the 08M2 program) I will be okay.
Correct, but because RAM locations $50 to $7F exist you don't need to alter $50 to 28 if you don't want to. There will be an unused gap in RAM after 'b27' up to $4F but that shouldn't be a problem.
 

IronJungle

Senior Member
Correct, but because RAM locations $50 to $7F exist you don't need to alter $50 to 28 if you don't want to. There will be an unused gap in RAM after 'b27' up to $4F but that shouldn't be a problem.
Hmmmm....that is what I thought as well when I read the manual. But, since something wasn't working I just assumed the $50 to 28 edit would correct it.

Now that I am "smarter" than I was last night I will go home and run some experiments. Then I may have to post some code to figure this out, because from what I get from your post, hippy/westaus, the program should work with the PEEK/POKE commands in the $50 to $7F range without modification.

Now... off to the lab...
 
Last edited:

IronJungle

Senior Member
Okay. More news from the labs....

First off, I verified that it does not matter (as you both suggested) if I use $50 or 28 as the starting PEEK/POKE address. Results were the same. What does seem to matter is which PICAXE O8M2 that I use. I simplified the code the the bare minimums just to confirm that I understood the PEEK/POKE as this was my first time using it on the PICAXE. It didn't work. Hmmmm..... I pulled a PICAXE 08M2 from an existing project and stuck it in my dev board. And.... problem solved. It worked as expected.

So that seems to indicate that the PICAXE 08M2 that I was using for my dev experiment was bad. But... this "bad" O8M2 seems to work fine in the project I used as the donor (see: http://www.picaxeforum.co.uk/showthread.php?19811-PICAXE-MQ2-Gas-Sensor-Project-in-a-Mouse).

So, it seems that the PICAXE I asked the question about doesn't work with the PEEK/POKE command, but works in the Methane Detecting Mouse.
The donor PICAXE from the Methane Detecting Mouse seems to work fine with the PEEK/POKE command.
Both PICAXEs are 08M2 and I find that behavior interesting because it points to a faulty 08M2. (I guess)

Anyway. I really appreciate the guidance and I am off the seek my next problem on this project.

Thanks all!
 

hippy

Ex-Staff (retired)
It would be interesting to know why one 08M2 works and another doesn't. Possibly there is something damaged but it could be a subtle 'borderline' issue of hardware. We don't know your hardware nor program so perhaps post both then we can see if there is something that stands out. It would also be worth knowing the firmware versions of each 08M2.

What I'd suggest is to run some SFR tests on each 08M2 to see if any obvious internal failure shows up. This should run without printing any FAIL messages ...

Code:
#Picaxe 08M2
#Terminal 38400
#No_Data

SetFreq M32
Pause 8000
SerTxd( "Started", CR, LF )
Do
  SerTxd( "Pass #", #s_w1, CR,LF )
  bPtr = 0
  Do
    @bPtrInc = s_w1 + bPtr
  Loop Until bPtr = 0
  Do
    s_w2 = s_w1 + bPtr & $FF
    If @bPtrInc <> s_w2 Then
      Do
        SerTxd("FAIL")
      Loop
    End If
  Loop Until bPtr = 0
  s_w1 = s_w1 + 1 
Loop
 

Armp

Senior Member
I simplified the code the the bare minimums just to confirm that I understood the PEEK/POKE as this was my first time using it on the PICAXE. It didn't work. Hmmmm..... I pulled a PICAXE 08M2 from an existing project and stuck it in my dev board. And.... problem solved.
Have you posted the code as Hiipy asked? I don't see it?
 
Top