View previous topic :: View next topic |
Author |
Message |
aalmoraa
Joined: 25 Jun 2010 Posts: 2
|
basic LED-BLINKING circuit |
Posted: Fri Jun 25, 2010 3:50 am |
|
|
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: 19543
|
|
Posted: Fri Jun 25, 2010 4:55 am |
|
|
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
|
|
Posted: Fri Jun 25, 2010 5:46 am |
|
|
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
|
|
Posted: Fri Jun 25, 2010 11:56 pm |
|
|
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 |
|
|
|