Internal pull ups

Mycroft2152

Senior Member
Hippy,

Will you give a brief explanation of the internal pull up resistors inside a PICAXE.

The question is whether they can be used instead of external pullups on inputs with switches.

Myc
 

hippy

Ex-Staff (retired)
I consider them to be N x resistors from I/O pins, each to a switch ( controlled by a bit in an SFR, $95 for 08M ) all to another master switch ( bit 7 of $81 for an 08M ) to +V. When enabled they are just like adding an external R to +V.

They worked okay on an 08M as pull-ups for switches to 0V for me.

What specific problems are you encountering ?
 

hippy

Ex-Staff (retired)
This works for me on an 08M. Indicates which of Input Pin 1, 2 or 4 are connected to 0V ( ie, switch closed ) no external pull-ups. There's no pull-up ability on Pin 3 of a PICAXE-08M ...

#Picaxe 08M
#Terminal 4800

Symbol OPTION_REG = $81
Symbol WPU = $95

Peek OPTION_REG, b0
bit7 = 0
Poke OPTION_REG, b0

Peek WPU, b0
bit1 = 1
bit2 = 1
bit4 = 1
Poke WPU, b0

Do
If pin1 = 0 Then : Sertxd( "1" ) : End If
If pin2 = 0 Then : Sertxd( "2" ) : End If
If pin4 = 0 Then : Sertxd( "4" ) : End If
Loop

Added : If you use SLEEP or NAP, you have to re-clear bit 7 of OPTION_REG.
 
Last edited:

Mycroft2152

Senior Member
I am working with a 20M for the Gadget Gangster Father's Day Contest entry.

It will save some space and fit better by using the internal pull ups.

Thanks

Myc
 

hippy

Ex-Staff (retired)
You're severly limited on the 20M due to the way the PICmicro ports are allocated. Only Port A and B have pull-ups and only two of those pins are on the left as inputs - Input Pins 0 and 7.

The SFR for pull-ups on Port B is above $FF so inaccessible but it resets with pull-up's enabled ( same for Port A ) so only have to set the global enable bit.

#Picaxe 20M
#Terminal 4800

Symbol OPTION_REG = $81

Peek OPTION_REG, b0
bit7 = 0
Poke OPTION_REG, b0

Do
If pin0 = 0 Then : SerTxd( "0" ) : End If
If pin7 = 0 Then : SerTxd( "7" ) : End If
Loop
 

hippy

Ex-Staff (retired)
The 18X has weak pull-ups on its Port B outputs, but they can be made inputs by poking SFR. You'd still need a current limiting resistor for when output initially and switch shorted to 0V so no real gain there.

The 18M is also Port B outputs, and no mechanism to make them inputs.
 
Top