How to enable a Pullup
John Abshier
Posts: 1,116
With help of the forum I have a pulldown working but have hit the wall on pullups. The magic line for pulldowns was
I tried the following not so magical line
Here is my test code
'LLL
wrpin ##%010_00_00000_0,pin '15k pulldown
I tried the following not so magical line
'HHH LLL
wrpin ##%010_000_00_00000_0,pin '15k pullup
[
That didn't work. I always got a low reading from the pin. If I didn't try to set the pullup, I got serveral lows, then several highs ...Here is my test code
CON
oscmode = $010c3f04 'standard stuff
freq = 160_000_000
baud = 230400 'must configure RUN command to match this
thepin = 40
OBJ
ser: "PrintfSerial" 'access to Propellor output (output only)
pins: "Pins2.spin2"
var
pub main | pinInput
clkset(oscmode, freq)
ser.start(baud) 'start up serial terminal
waitcnt(freq * 2 + cnt)
ser.str(string("Pullup Pulldown Input test"))
ser.nl
pinInput := In(thepin)
ser.str(string("Nothing Set pin = "))
ser.dec(pinInput)
ser.nl
SetPullup(thepin) ' if not called varies high and low if called always low
repeat
waitcnt(clkfreq / 10 + cnt)
pinInput := In(thepin)
ser.str(string("Pullup Set pin = "))
ser.dec(pinInput)
ser.nl
repeat
PUB In(pin) : state
asm
testp pin WC
if_c addx state, #0
endasm
PUB SetPullup(pin) '************* not working
asm 'HHH LLL
wrpin ##%010_000_00_00000_0,pin '15k pullup
dirh pin
endasm
PUB SetPulldown(pin) 'tested with Control Board and worked
asm 'LLL
wrpin ##%010_00_00000_0,pin '15k pulldown
dirh pin
endasm

Comments
higher channel resistance? If so you'd need to enable the output high side to get pullup
For the pulldown, you were setting dirh high correctly to enable the driver and resistor, but benefiting from Outa defaulting to low. For pullup you'll actually need to set outa.
I can't check right now though
Mike
My project is to write an object to provide BS2/Arduino functionality/simplicity. So far I have Hi, Low, Toggle, In, Set Pullup, and Set Pulldown. I need to rewrite Hi, Low, Toggle using fastspin's builtin's to save a clock over by inline assembly.
John Abshier
To tell if a smartpin is on or off then check the %MMMMM bits. If all zero then no smartpin, anything else and you have a smartpin active.
- A, B and F are general digital input config. These stand independent.
- T is digital output config although it interacts with both P and M.
- M is smartpin mode. Lots to learn here ... but learn it for one pin and you know them all.
- P is all about the custom pin controls. Configuring sense types and drive strengths, pin feedback and other little details, DAC and ADC have their own setup here too. The details of each bit can change depending on T and M.