# beginner with pic16f767

Status
Not open for further replies.

#### frubo

##### New Member
I am new to programming pics and this is the second one I've bought. I programmed my first to output patterns to LEDs with ease but this a more advance one giving me problems right off the bat. I am simply trying to light an LED so that I can later get it to blink but I am not getting any output at all.

Code:
list             p=16f767
#include	<P16F767.inc>
;**********************************************************************
ORG		0x000

BCF STATUS, RP0 ;bank 1

MOVLW	04H   ; 4mhz clk
MOVWF	OSCCON

MOVLW 0x0F ; Configure all pins

MOVLW 0x00 ;all output
MOVWF TRISA

BCF STATUS, RP1 ; Bank0
MOVLW	01H          ; set RA0 high
MOVWF     PORTA

LOOP
nop
goto	LOOP

END
I am using INTRC_CLKOUT in my fuses settings too. I am not sure if I set something up wrong or what. I am using 2 AA batteries, VDD to positive VSS to negative, and the LED at RA0. What am I doing wrong?

#### Pommie

##### Well-Known Member
You seem to have your bank switching muddled up.
Code:
		list	p=16f767
#include	<P16F767.inc>
;**********************************************************************
org	0x000

b[COLOR="Red"]s[/COLOR]f	STATUS,RP0	;bank 1

movlw	[COLOR="Red"]62[/COLOR]H		; 4mhz clk
movwf	OSCCON

movlw	0x0F		; Configure all pins

movlw	0x00		;all output
movwf	TRISA

bcf	STATUS,RP[COLOR="red"]0[/COLOR]	; Bank0
movlw	01H		; set RA0 high
movwf	PORTA

LOOP
nop
goto	LOOP

end
Also, your OSCCON value was wrong.

Mike.

#### frubo

##### New Member
I changed those lines of code and it still does not work. Could what I had before have ruined the device? I am getting output only on pin 10 but I believe that is just the clock output. No other pins are high.

also these are my fuse settings and Im not sure if they are correct.

WDT- Enabled
MCLRE - Enabled
Brownout Voltage - 2.0V
Code Protected - Disabled
Clock Monitor - Enabled
PWRTE - Disabled
BOREN - Enabled
CCP2 Mux - RC1
Oscillator - INTRC_CLKOUT
Int/Ext Switch - Enabled

I dont know what half of these mean so most of them I just left as default.

#### frubo

##### New Member
alright i figured out it is not my code but something weird is going on. The LED lights but only sometimes. I programmed the pic stuck it in the breadboard, powered it and the LED came on. I disconnected the power and powered it up again...no light. It comes on sometimes and other times it doesnt, I am not changing the programming either.

#### nickelflippr

##### Member
If you are not going to clear the watchdog timer in software, then disable it in the config.

#### frubo

##### New Member
I disabled the watchdog timer and int/ext switch. I dont know that either of those were the problem but I have discovered something. I am using 3 AA batteries now and getting better results. I can consistently get the LED to light up but...if I power the chip with the LED and resistor connected to the RA0 pin it doesnt work. If I power the chip then afterwords connect the LED and resistor to the pin it does work. (It also works if I disconnect and reconnect the LED while the chip is powered).

#### nickelflippr

##### Member
Not sure what exactly is going on with your power supply, but using dead batteries is going to cause all sorts of problems. Having the PWRTE enabled would give you a more stable clock on startup, or reset, if that is the trouble?

#### frubo

##### New Member
figured it out. disabled MCLRE and now it works perfectly even with 2 AA. not sure why i just started trying different combinations of fuses. thanks for the help.

#### blueroomelectronics

##### Well-Known Member
What programmer did you use?

#### frubo

##### New Member
Status
Not open for further replies.