CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

very simple problem with 16f84a

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wazzy



Joined: 27 Feb 2005
Posts: 5

View user's profile Send private message

very simple problem with 16f84a
PostPosted: Mon Apr 18, 2005 5:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 18, 2005 5:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 18, 2005 5:53 pm     Reply with quote

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 Smile
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 18, 2005 6:22 pm     Reply with quote

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








PostPosted: Tue Apr 19, 2005 4:40 am     Reply with quote

thanks a lot! Im gonna have a look now, but that really helps!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group