Internal pull-ups

RadioBob

New Member
Could someone tell me briefly if there are internal pull-ups for input pins on the 08M and if yes, how to invoke them or are input pins always being pulled up?
 

hippy

Technical Support
Staff member
There are internal weak pull-ups selectable for individual pins except Pin 3 ( Leg 4 ). These are set through the "WPU" SFR at $95 and the "GPPU" flag in "OPTION_REG" at $81 must be cleared.

This should in theory give Input 1 a weak pull-up but hasn't been tested ...

Code:
Symbol Option_REG = $81
Symbol WPU        = $95

Peek OPTION_REG, b0
bit7 = 0
Poke OPTION_REG, b0

Peek WPU, b0
bit1 = 0
Poke WPU, b0

Do
  SerTxd ( "Pin1 = ",#pin1,CR,LF)
  Pause 500
Loop
For more information have a look at the Microchip datasheet for the 16F683 and a Forum Search may be worthwhile because I'm sure internal pull-ups have been discussed before ( Brightsparks Andrew ? ).
 

kranenborg

Senior Member
Just checked the standard settings of the registers that hippy mentioned after power-up of a 08M:

Option_REG = 255 (%11111111)
WPU = 55 (%00110111)

This means that the individual pullups bits are all set (WPU) but the pullups are still not active because the GPPU bit in Option_REG is 1, which means that all pullups are disabled

This would imply that for setting the 08M's internal pullups on all inputs it is sufficient to write POKE Option_REG = %01111111. The pullups get disabled when an input is made an output, but get restored again when the output is turned to an input.

This saves quite a few bytes which counts heavily on the 08M for my application (I am extending the master node code of the SerialPower network stack) but assumes that the firmware settings for these registers will remain unaltered the coming centuries ...
I have not checked for the other picaxes.

/Jurjen
 
Last edited:
Top