No Exit. I cannot understand this behaviour.

lauriet

Member
I am making a fairly simple system, switch inputs, LED outputs, moderately clever stuff in between, using an 18M2 and Picaxe Editor 6.0.8.11 in Windows 10 on a modestly sufficient Minix box.
Having built and loaded a prototype, I was trying to track down some irrational behaviour but the 'debug' command seemed to lock up the Editor, so I have been using the simulator to explore the code (must learn to set variable values; stepping through is tedious), and noticed something I cannot understand.
I have reduced the code to this for demonstration:

Code:
;init:
#picaxe 18m2

main:
Do
	if pinC.0 = 1 then
		b0 = b0 + 1
	Endif
	if b0 > 10 then
		high B.1
		do while pinC.0 = 1;wait till input low
		loop
		exit
	endif

	if pinC.1 = 1 then
		b1 = b1 + 1
	Endif
	if b1 > 10 then
		high B.1
		do while pinC.1 = 1;wait till input low
		loop
		exit
	endif
loop

result:
low B.1
All it does is detect a high input, set an output high after a while, then set the output low when the input goes low; obviously it is inelegant, but shadows the process required in the 'proper' software.
Whilst it works as I would expect when the C.1 input is used, exiting throught to Result:, using the C.0 input locks the simulator up on the 'exit' command on line 13. I cannot understand this.

What is more baffling is that if I comment out the 'do ...loop' lines in the C.1 section, the C.0 sequence then exits properly.
The way out of the freeze seems to be taking the C.4 input high.
Could someone out there comment if this is a problem with the simulator, a stupidity or lack of understanding on my part or my PC running out of puff?
Many thanks.
 

Attachments

Buzby

Senior Member
I don't know why its locking up, but I do know you don't need the 'exits'.

The usual syntax is 'IF something THEN EXIT', not just 'exit' on its own.
 

hippy

Technical Support
Staff member
This does appear to be an issue with simulation which we will investigate.
 
Top