Simulation Bug?: Timer interrupt does not wake 20X2 simulation from the "DOZE 0" command.

Flenser

Senior Member
I've just been using the X2 timer interrupt for the first time and struck this behaviour in simulation.

I'm using PE v6.1.0.0
The simulation is run with a delay of 30ms because this allows you to see the line of code that is being executed.
The timer settings are set so that the timer interrupt happens about ever 2 sec while being simulated on my X200 laptop.

First, run this code with the "DOZE 0" command commented out to demonstrate that the timer interrupt is being triggered. On my laptop the terminal output shows: mmmmmImmmmmImmmmmImmmmmmImmmmmI
Code:
#NO_DATA
#NO_TABLE
#PICAXE 20X2
SETFREQ M4

; Set a polled interrupt on the timer0 overflow
SETINTFLAGS %10000000,%10000000

; Set timer0 so that it occurs frequently during simulation
SETTIMER t1s_4
timer=65534

Main:
    SERTXD ("m")
    ; DOZE 0
GOTO Main

interrupt:
    timer=65534

    SERTXD ("I")
    
    ; We need to re-enable our interrupt. This won't take effect until after we return.
    SETINTFLAGS %10000000,%10000000
    toflag=0
    RETURN
Then uncomment the "DOZE 0" command and rerun the simulation. This time the program stops at the DOZE command. The interrupt subroutine is never called.
 

AllyCat

Senior Member
Hi,

The Command Description says that "'doze 0' puts the microcontroller into permanent doze..". Isn't that what's happening?

EDIT: I will concede that it goes on to say "The microcontroller is only woken by a hardware interrupt (e.g. .. timer tick)" but remember that it is a "Program Code Simulator" it is NOT a PIC(axe) "Hardware Emulator". It is well-known that the Simulator does not handle many hardware features such as access to the SFRs. Basically the Program says "Stop" and there is a command warning that new Downloads (system interrupt driven) will NOT be executed. Maybe the simulator could be re-written to accommodate this Doze 0 behaviour, but a simple "fix" would be to use a very large value such as 65535 instead of 0.

Cheers, Alan.
 
Last edited:

Flenser

Senior Member
AlleyCat,

I did not make my post clear enough. I was not after a workaround.

The simulator does correctly simulates the "doze 0" command.
The simulator does correctly simulate the timer interrupt.
The simulator does correctly simulate a pin change interrupt waking the program from "doze 0".
The simulator does not correctly simulate a timer interrupt waking the program from "doze 0".

I've provided this bug report purely as a courtesy for RevEd. They are free to ignore or action it as they see fit.
 
Last edited:
Top