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

basic LED-BLINKING circuit

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



Joined: 25 Jun 2010
Posts: 2

View user's profile Send private message

basic LED-BLINKING circuit
PostPosted: Fri Jun 25, 2010 3:50 am     Reply with quote

Hi all!!

I tried to blink a led and I can't as expected. I attached the code and the circuit. The hex file is working with ISIS properly. Can anybody tell me the mistakes??

Thanks in advance...

Code:

#include <16F877A.H>
#use delay (clock = 20000000)
void main(void) {

while (1) {
output_high(PIN_A0);
delay_ms(1000); // Delay 1s
output_low(PIN_A0);
delay_ms(1000); // Delay 1s

}
  }





[/code]
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Jun 25, 2010 4:55 am     Reply with quote

First, fuses. You need:
#fuses HS,NOWDT,NOLVP,NODEBUG,PUT,BROWNOUT
as the second line (the first three are 'vital', the rest just 'helpful'). Without the first, the PIC doesn't know what oscillator to use....

Second, there may also be a problem with the oscillator. These jumper boards have significant capacitance, and you may find the oscillator doesn't want to start, and run at the proper frequency 'in board'.

I'd actually stick the 100nF, adjacent to the PIC pins, rather than on the rail.

Best Wishes
aalmoraa



Joined: 25 Jun 2010
Posts: 2

View user's profile Send private message

PostPosted: Fri Jun 25, 2010 5:46 am     Reply with quote

Thank you very much Ttelmah!!! Fulfilling your first advise worked!!! Frankly, I didn't expect to have a software problem. It means that I should focus on the software part...

Can you advise me a book that have codes that works with real MCUs, not only with ISIS??? The book I have isn't good enough I guess...
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Fri Jun 25, 2010 11:56 pm     Reply with quote

Quote:
Can you advise me a book that have codes that works with real MCUs
A nice place to start is the examples folder of CCS. There are lots of example programs ranging from easy-to-do-stuff all the way to interrupts, using libraries, and the like. Most of the examples have decent documentation, so understanding will not be a problem.

Read the code, modify it to suit your needs, and then write new programs :-)

Rohit
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