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
MOVWF ADCON1 ; as digital
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?
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.
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.
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).
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?
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.