Internal pullups not working on PIC12F675

Status
Not open for further replies.

Yobortsa

Member
Hi all,

Does anybody have any idea why internal pullups might be working on GPIO5 but not GPIO4 on a PIC12F675?

Code:
RESET	clrf	STATUS			;
		clrf	GPIO			; Init GPIO
		movlw	b'00000111'		;
		movwf	CMCON			; comparator off, digital I/O
		bsf     STATUS,RP0      ; bank 1                          |B1
        call    h'3FF'          ; get factory calibration value   |B1
        movwf   OSCCAL          ; set OSCCAL calibration value    |B1
		movlw   b'00111000'     ; Set 0,1,2 to outputs; 3,4,5 to inputs (switches)
        movwf   TRISIO          ; 
		movlw	b'00110000'		; Enable port 4,5 pullups
		movwf	WPU				; Set Weak Pull Up register
  		bcf     OPTION_REG, 7	;  Enable Pull Ups
        bcf     STATUS,RP0      ; bank 0                          |B0

I have tried programming with PICKit1 and PICKit2 and on test boards with connections going nowhere GPIO5 works fine (5V) but GPIO4 has varying voltage below 1.3V. I have tried with 3 PIC chips. Have also tried in my circuit which has GPIO4 and GPIO5 going to ground via microswitches. I never get GPIO4 held high with internal pullup. Do I need to disable the Analog port somehow perhaps?

Regards,

David
 
Yes you need to clear the bit in the ANSEL register to set the port bit to digital mode. Check the datasheet for more info.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…