setintflags & flags

BeanieBots

Moderator
PE V5.3.2
40X2 firmware B.3

The following code does not behave as expected in either silicon or simulation.

Code:
#picaxe 40x2
flags=0
hintsetup %01110111
setintflags %00001000,%00001000

do:loop

interrupt:
setintflags  %00001000,%00001000
sertxd (#flags," ",#pinsB,cr,lf)
flags=0
return
pinsB reports the expected value but flags reports as follows:-

B.0 activated = 10 (as expected)
B.1 activated = 10 (expected 11)
B.2 activated = 12 (as expected)

Something I'm doing wrong or a bug?
 
Last edited:

Technical

Technical Support
Staff member
Assume you mean B.1 on the second line.
But your code does flags then pinsB, so are you actually suggesting #pinsB is incorrect?
 

BeanieBots

Moderator
Yes, I did mean B.1 (edited post for clarity)

pinsB is giving the expected value in so far as it indicates which of B.0-B.2 has been pressed. However, flags suggests that B.0 and B.1 both set the same software flag.

This code makes the problem more obvious:-
Code:
#picaxe 40x2
flags=0
hintsetup %01110111
setintflags %00001000,%00001000

do:loop

interrupt:
b0=pinsB
sertxd (#bit3,#bit2,#bit1,#bit0," ",#flag3,#flag2,#flag1,#flag0,cr,lf)
flags=0
setintflags  %00001000,%00001000
return
It is not possible to distinguish between B.0 & B.1 from the status of "flags".
Both B.0 and B.1 set flag1. (B.0 should set flag0)
 
Last edited:

hippy

Ex-Staff (retired)
Odd, can confirm the Simulation issue but code seems to be working with my PICAXE-40X2 Firmware B.3 ...

Code:
#picaxe 40x2

Gosub Interrupt_Enable

do:loop

interrupt:
  sertxd ( #flags, 9 )
  sertxd ( #hint2Flag, #hint1flag, #hint0flag, 9 )
  sertxd ( #pinB.2, #pinB.1, #pinB.0, CR, LF )

Interrupt_Enable:
  flags=0
  hintsetup %01110111
  setintflags %00001000,%00001000
  return

9	001	001
9	001	00[b]0[/b]
10	010	010
10	010	010
12	100	100
10	010	010
9	001	001
9	001	00[b]0[/b]
The #pinB.0 zero readings bolded are button bounce.
 

BeanieBots

Moderator
Thanks Hippy.
I added 56k/100nF debounce on the buttons and I can now confirm your findings.
Now works OK on silicon B.3 but simulation is wrong. (Int0 sets flag1:()

At least I can crack on with the hardware, including debounce fix:)
 
Top