Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC16F877A basic LED-BLINKING circuit

Status
Not open for further replies.

mansiz

Newbie level 3
Joined
Sep 28, 2006
Messages
4
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Activity points
1,307
Hi all!!

I tried to blink a led and I can't as expected. I use CCS C. The hex file is working with ISIS properly. The code and the circuit are attached below. 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

}
  }

 

A0 is usually an analog input. You might have to change it to a digital one by setting tristates.
OR you can simply put the LED into any of the pins on port D(like pin D1) and change your code accordingly.
 

Hi,
Try this:
Code:
#include <16F877A.H>
#use delay (clock = 20000000)
void main(void) {
TRISA = 0;
ADCON1 = 7;

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

}
  }

I don't really know CCS but try it and set the configuration bits accordingly. Turn Watchdog timer off, set appropriate oscillator setting, etc. I don't know how to do that in CCS, but configure these.

Hope this helps.
Tahmid.

Added after 35 seconds:

I see you have a 20MHz crystal, so set oscillator as "HS"
 

    mansiz

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
Changing the configuration bits with adding the code following line worked!!! The LED is blinking...

#fuses HS,NOWDT,NOLVP,NODEBUG,PUT,BROWNOUT

Thanks for your help!!!
 
hi,
Please what exactly are u referring to as configuration bits?
 

Configuration Register is a 16 bit register in the controller with each bit having different functions.Refer page no: 144 of the data sheet for PIC16F87XA.It is explained beautifully over there.
Regards,
Jerin.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top