pinsB in simulation

cpedw

Senior Member
I'm running the latest PE 6.1.0.0. The following code snippet (part of modified firmware for the AXE131Y) appears not to alter pinsb in the simulator. Looking at Code Explorer/System or hovering the cursor over pinsb in the code insist on showing it as 0 all the time.
Code:
#picaxe 18M2
symbol enable     = C.6    ; LCD enable
symbol rs         = C.7    ; LCD RS 

symbol hr        = b5    ; Hour counter
symbol mn        = b6    ; Mins counter

hr = 0
mn = 2

Distime:        ;Show current hour, mins
    LOW RS                    
    pinsB = 130
    pulsout enable,1
    HIGH RS
    pinsb = "0" + hr
    pulsout enable,1
    pinsb = ":"
    pulsout enable,1
    pinsb = mn / 10 + "0"    ; Tens of minutes
    pulsout enable,1
    pinsb = mn // 10 + "0"    ; Units of minutes
    pulsout enable,1
END
Is this a flaw in the simulator or am I doing something wrong?

Derek
 

lbenson

Senior Member
For assignment to the B port pins, you need to use "OUTPINSB=130".
outpinsb.jpg
But ... that doesn't work in simulation for me either:
outpinsb_sim.jpg
 

Aries

New Member
I thought you needed to specify which pins were outputs, because the default is "input". So you need
Code:
output b.7
output b.1
or equivalent, before "outpins", in order to make them outputs. "outpins" of itself just says set the values of the current output pins (whatever they happen to be)
 

cpedw

Senior Member
Thanks for that. Yes setting dirsb=255 fixes it.

I am now puzzled about pinsb/outpinsb. I based my code on the AXE133 firmware. It uses pinsB so I did (it also sets dirb, which I forgot!) . It seems that pinsB and outpinsB both get set together:
1581933519021.png
That puzzles me but I seem to be getting what I need.

Derek
 

hippy

Technical Support
Staff member
I am now puzzled about pinsb/outpinsb. I based my code on the AXE133 firmware. It uses pinsB so I did ... It seems that pinsB and outpinsB both get set together:
When writing, both 'pinsB' and 'outpinsB' set the port B pins which have been configured as output pins, so either can be used.

When reading 'pinsB' will read those port B pins which are inputs. Reading "outpinsB' will read how the port B output pins were set.
 

westaust55

Moderator
Nominally outpins<port>
is used on the left side of an equation to set the state (high or low) for each pin of the designated port.

pins<port> when used on the right side of an equation reads the pins and returns the data into the variable on the left side of the equation.

edit: see hippy answer above
 
Top