Pin5/GP2 won't go high

Thread Starter

jpanhalt

Joined Jan 18, 2008
11,087
I have been struggling for 2 days with a program for a PIC 12F509.
Odd things were happening, so I wrote a simple test program:

Rich (BB code):
;**********************************************************************

    list      p=12F509            ; list directive to define processor
    #include <p12F509.inc>        ; processor specific variable definitions

    __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC

;   __CONFIG 0FFA 



;***** VARIABLE DEFINITIONS

List	
d1	equ	0x11
d2	equ	0x0b

;*******************************************************************
RESET_VECTOR
    ORG   0x3FF      ; processor reset vector

; Internal RC calibration value is placed at location 0x3FF by Microchip
; as a movlw k, where the k is a literal value. 
    
MAIN
    ORG    0x000
    movwf   OSCCAL            	; update register with factory cal value 


start   
   	movlw	b'001000'			; sets all pins to output, except GPIO,3 (pin4) 
	tris	GPIO
flash
	movlw	b'110111'			; sets all pins high
	movwf	GPIO
	call	dly_2E5
;	movlw	b'000000'			; sets all pins low
;	movwf	GPIO
;	call 	dly_2E5
	goto	flash

dly_2E5
	clrwdt
	movlw	0x3f
	movwf	d1
	movlw	0x9d
	movwf	d2
delay
	decfsz	d1,f
	goto	$+2
	decfsz	d2,f
	goto   delay
	retlw	0

    END                       ; directive 'end of program'
Try as I may, I cannot get pin 5 (GP2) to go high. I have tried 4 dip chips (one was new), 3 SOIC chips (2 were new), two computers (one had a real serial port, the other used a USB to serial adapter cable), and 2 programmers (PicStart Plus and Inchworm --an MPLAB ICD2 emulator).

Both computers and programmers, including the adapter cable, had worked in the recent past. Contact to the #5 pin have been checked and appear to be OK.

I need a fresh brain and set of eyes to look at this for possible problems/solutions.

Thanks.

John
 
Last edited:

gryskop

Joined Mar 1, 2008
26
Rich (BB code):
	MOVLW	B'11000000'	; Weak Pullup resistors
	OPTION			; disabled
	MOVLW	B'00001000'	; Set only GP<3> as Input
	TRIS	GPIO		; Set GP<5,4,2,1,0> as outputs
I used this in my code for a 12C509 application and it does allow GP2 to operate.

BTW, how long is your delay loop suppose to be? It seems to be in a loop?
 

AlexR

Joined Jan 16, 2008
732
The obvious question that springs to mind is do you have a pull-up resistor connected between Vdd and pin4 (MCLR).
 

Thread Starter

jpanhalt

Joined Jan 18, 2008
11,087
@gryskop: Thanks loads. Great catch on the Option register.

For several other programs that work, I set Option as needed, and pin 5 works as expected (like in my spot welder). In this case, since GP2 does not have a weak pullup, I assumed it wouldn't be affected and neglected to pay any attention to the Option register. I wonder where it is documented in the datasheet?

@AlexR: Problem is solved. Yes, I had MCLR tied high.

Thanks all.

Edit: Delay loop is 200 mS (I use 2E5 to mean 2X10E5 microseconds); edit#2 fixed error in loop above

John
 
Last edited:
Top