
Originally Posted by
teilhardo
I plan to use the internal oscillator (and I think that I put that parameter into the programmer software right).
See this thread http://www.picbasic.co.uk/forum/showthread.php?t=543
/MCLR is the PIC reset pin. It can also serve as an input pin on PICs with the option of turning off the /MCLR reset function.
See this thread & the data sheet. http://www.picbasic.co.uk/forum/show...highlight=MCLR
You might want to start out by building the circuit shown in your manual to blink the LED. Here's a simple blink program for your PIC. Note this does not require the external oscillator or resistor from Vcc to the /MCLR pin as shown in your PBP manual.
Code:
@ DEVICE PIC16F628,MCLR_OFF,LVP_OFF,INTRC_OSC,WDT_OFF
Main:
HIGH 0
PAUSE 1000
LOW 0
PAUSE 1000
GOTO Main
END
The first thread by Melanie explains what's up with the first line. It's well worth reading for anyone just getting started.
Now, let's assume you build the "It's Alive" circuit exactly as shown in your manual, but you use the 16F628 VS the 16F84.
Code:
@ DEVICE PIC16F628,MCLR_ON,LVP_OFF,XT_OSC,WDT_OFF
Main:
HIGH 0
PAUSE 1000
LOW 0
PAUSE 1000
GOTO Main
END
Now /MCLR functions as the external device "reset" so you need the 4.7K pull-up from Vcc to the /MCLR pin, and you'll need the external crystal as shown in the It's Alive circuit example.
Another option since you're using batteries is to use the WDT (watch dog timer). This example puts the PIC to sleep for the delay periods you want, and controls the LED.
Code:
@ DEVICE PIC16F628,MCLR_OFF,LVP_OFF,INTRC_OSC,WDT_ON
Main:
HIGH 0 ' LED on here
SLEEP 60 ' Enter low power mode for around 1 minute
LOW 0 ' LED now off
SLEEP 300 ' Enter low power mode for around 5 minutes
GOTO Main ' Repeat the process
END
This example doesn't require the resistor to /MCLR, and uses the internal oscillator. This version will make those tiny little AA batteries last a good deal longer too. When in SLEEP mode the PIC uses very little power. This example is sleeping for the majority of your time delay periods.
With the MeLabs serial programmer, make sure you have a check mark next to the two following things under the Options menu;
Update configuration from file <-- this uses the config fuse options embedded in your .HEX file.
Reread file before programming <-- this makes sure you're always loading & using the latest version of your code after it's been compiled.
Now try your original example, but add the @ DEVICE line shown below to the top.
Code:
@ DEVICE PIC16F628,MCLR_OFF,LVP_OFF,INTRC_OSC,WDT_OFF
loop:
high 1
pause 60000
low 1
pause 60000
pause 60000
pause 60000
pause 60000
pause 60000
goto loop
This should get you started, but nothing is going to help you more than reading through the 16F628 data sheet, PBP manual & examples, and your programmers help file.
All this stuff will make a lot more sense once you have....;o}
Bookmarks