Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 14th November 2009, 11:55 AM   #1
Red face Internal pullups not working on PIC12F675

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
Yobortsa is offline  
Old 14th November 2009, 12:31 PM   #2
Default

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.
__________________
Pete
picprojects.org.uk
geko is offline  
Old 14th November 2009, 12:44 PM   #3
Smile

Yep, worked - thankyou so much

Code:
clrf ANSEL
Yobortsa is offline  
Reply

Tags
12f675, internal, pic, pullup, pullups, working

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Pullups - Rule of thumb? UTMonkey General Electronics Chat 5 10th May 2008 08:07 AM
PIC12f675 MERV Micro Controllers 18 10th December 2007 08:18 PM
Reprogramming PICs with Internal OSC on & MCLR disabled (internal) Inchworm+ blueroomelectronics Micro Controllers 5 11th April 2007 05:10 PM
BAD night.. 16F628A weak pullups. mramos1 Micro Controllers 6 12th December 2006 05:57 PM
internal comparator - table (pic12f675) alamy Micro Controllers 3 30th September 2004 06:55 AM



All times are GMT. The time now is 01:25 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker