View previous topic :: View next topic |
Author |
Message |
wazzy
Joined: 27 Feb 2005 Posts: 5
|
very simple problem with 16f84a |
Posted: Mon Apr 18, 2005 5:18 pm |
|
|
Im a beginner programmer with the ccs compiler. I found a lot of sample codes in this forum, but I am having problems making sense out of it all! Im trying to write a very simple program for the pic16f84a. All I want is a simple program that generates a square wave (any frequency). The actual generation of the square wave is no problem, but my biggest problem is making sense out of all the include's and define's and fuses. I just dont understand how they work! I really need help and as soon as possible! Thanks anyway for any help you can provide. If someone can just help me out with a simple tutorial or just give me guidance in this issue, I would really appreciate it! (by the way, Im using a 4MHz crystal with the pic16f84a. Is this suitable?)
Again, thanks a lot! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 18, 2005 5:23 pm |
|
|
Quote: | All I want is a simple program that generates a square wave (any frequency). |
Code: | #include <16F84A.H>
#fuses XT, NOWDT, NOPROTECT, PUT
#use delay(clock=4000000)
//===================
void main()
{
// Generate a 1 KHz square wave on pin B0.
while(1)
{
output_high(PIN_B0);
delay_us(500);
output_low(PIN_B0);
delay_us(500);
}
} |
|
|
|
wazzy
Joined: 27 Feb 2005 Posts: 5
|
|
Posted: Mon Apr 18, 2005 5:53 pm |
|
|
first of all: thanks :D
I was wondering if you could explain all the fuses. Should I set these fuses when programming the pic? How do I decide which fuses to choose. And where can I find a list of all the possible fuses?
Again, thanks a lot for the code |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 18, 2005 6:22 pm |
|
|
Get the 16F84A data sheet from here. Go to section 6.0,
"Special Features of the CPU", and look at section 6.1 on Configuration
Bits. These are what CCS calls "fuses". Read the rest of section 6
for more info on this.
http://ww1.microchip.com/downloads/en/DeviceDoc/35007b.pdf
For a list of all possible fuses for your PIC, look at the start of the
16F84A.H file. |
|
|
Guest
|
|
Posted: Tue Apr 19, 2005 4:40 am |
|
|
thanks a lot! Im gonna have a look now, but that really helps! |
|
|
|