Mike, Try initializing CMCON, then ANSEL, then TRISIO, and then enable WPU. Check the datasheet too. I think there is note someplace in there that talks about the sequence in which they should be initialized. Shahid. -----Original Message----- From: Mike Hord [mailto:gaidinmd@HOTMAIL.COM]=20 Posted At: Thursday, February 19, 2004 2:47 AM Subject: [PIC:] 12F675 GPIO won't pullup Sometimes the pull-ups work, sometimes not. I've changed pins, to check if it is a bad pin, and I've changed PICs, to see if it's a bad PIC, but I still have the problem that sometimes GPIO.0 (or GPIO.1, if I rewrite the code with that pin as the input) just doesn't pull itself high. I've been staring at this off and on for two days. What am I missing? I'm leaving out the interrupt handler, because all it does is strobe a pin, and the timing functions, because all they do is control the rate at which the pin strobes. After the code included here, the only special function registers that get touched are GPIO and INTCON. The program is a simple IR remote control intended to turn on and off a device for which the remote is prohibitively expensive. Mike H. __CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC calls EQU 0x20 ; temp to hold calls during wait loops codel EQU 0x21 ; low of the pertinent code codeh EQU 0x22 ; high of the pertinent code timeleft EQU 0x23 ; time left to add to make period 45 mS #DEFINE pwrbtn GPIO,0 ; alias to the button for power code #DEFINE led GPIO,1 ; alias to the IR led #DEFINE inpbtn GPIO,2 ; alias to the button for input code #DEFINE mutebtn GPIO,3 ; alias to the button for mute code CONSTANT ONECALLS=3D47 ; number of calls to encode a one CONSTANT ZEROCALLS=3D23 ; number of calls to encode a zero CONSTANT HEADERCALLS=3D95 ; number of calls to encode header CONSTANT PAUSECALLS=3D25 ; number of calls to wait between bits ;********************************************************************** ORG 0x000 ; processor reset vector goto main ; go to beginning of program main bsf STATUS,RP0 ; start initializing the registers in bank 1 clrf OPTION_REG ; turn on pull-ups, other funcs not important movlw b'00111101' ; mostly inputs, except GPI01, which is LED movwf TRISIO movwf WPU ; turn on pull-ups for each input channel movwf IOC ; turn on interrupt-on-change for each input clrf ANSEL ; needed for prototyping on 675 bcf STATUS,RP0 ; done initializing the bank 1 registers movlw b'10001000' ; turn GIE on, and GPIE on movwf INTCON movlw 7 ; turn comparator off movwf CMCON naptime sleep ; sleep while waiting for a button to be pressed goto $+1 ; give interrupt a moment to vector goto naptime ; go back to sleep END ; directive 'end of program' _________________________________________________________________ Dream of owning a home? Find out how in the First-time Home Buying Guide. http://special.msn.com/home/firsthome.armx -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body