Pull Up Resistors and the Pull Up Control Register of the HC9S12 Microcontroller Pull Up Resistor Circuits Pull Up resistors are used in logic circuits to allow for the generation of valid “0” and “1” logic voltages. In the circuit shown the switch is used to control the logic level present at Vout. When the switch is Closed the logic level is a zero (Vout = 0 V) and when the switch is Open the logic level is a one (Vout = 5 V). If the pull-up resistor is missing Vout will be a floating logic level. Pull Up Control Register - PUCR – address $0C The ports A, B K and E on the HCS12 workstation board have programmable pull-up resistors. 7 PUPKE 6 0 5 0 4 3 PUPEE 0 2 0 1 PUPBE 0 PUPAE Reset value = 0x90 PUPKE: Pull Up Port K Enable 0 = pull-up resistors of Port K are disabled 1 = pull-up resistors of Port K are enabled PUPEE: Pull Up Port E Enable 0 = pull-up resistors of Port E are disabled 1 = pull-up resistors of Port E are enabled PUPBE: Pull Up Port B Enable 0 = pull-up resistors of Port B are disabled 1 = pull-up resistors of Port B are enabled PUPAE: Pull Up Port A Enable 0 = pull-up resistors of Port A are disabled 1 = pull-up resistors of Port A are enabled 1 Using the PUCR register The pull-up resistors for a port must be enabled when a circuit connected as an input signal source to the port does not have its own pull-up resistors. For example the Switch and LED I/O Lab board has switch inputs and LEDs outputs does not have pull up resistors connected to the switches. It is necessary then to enable the pull-up resistors for any port to which these switches are attached. In D/A converter the switches are connected to Port A. Enabling the pull-up resistors could be done as follows in Assembly language PUCR: ….. ldaa #$91 staa PUCR equ $0C Question Why is $91 being loaded into the PUCR register? A better software programming approach would be PUCR: equ $0C ….. bset PUCR, $01 In C language programming this could be done as: PUCR = PUCR | 0x01; or PUCR |= 0x01; Application Note Written by David Lloyd Computer Engineering Program Humber College 2