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.

Flashing LED will not flash!

Status
Not open for further replies.

jaco1982

Newbie level 4
Joined
Oct 4, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,332
I think I'm going slightly mad! I'm quite new to embedded development (got a few years experience in server/client devving).
What I'm trying to do, is make a LED flash. Code is as follows:

Code:
void main() {
     TRISC = 0x00;
     PORTC = 0x00;
     
     for(; ;) {
           PORTC.F0 = 0xFF;
           delay_ms(500);
           PORTC.F0 = 0x00;
     }
     
}

I'm writing the code in MikroC, and simulating it in Proteus using a PIC18F4553 device. The LED goes on, but does not flash. Am I missing something?
 

Put another delay in before the end of the for loop.
 
you will need to read the datasheet a few times, specifically the sections on IO Ports and Configuration Bits.

and then read your compiler manual to see how to implement what you learned there.
 

Can you post the whole code? You need to configure your configuration pins properly as well as the clock
 

The LED was flashing but it was not in the off state long enough to see without an oscilloscope.

That was exactly it. I saw it when I put a scope on the output.
 

What if you change the "for (; ;)" instruction with "while(1)"
 

I think I'm going slightly mad! I'm quite new to embedded development (got a few years experience in server/client devving).
What I'm trying to do, is make a LED flash. Code is as follows:

Code:
void main() {
     TRISC = 0x00;
     PORTC = 0x00;
     
     for(; ;) {
           PORTC.F0 = 0xFF;
           delay_ms(500);
           PORTC.F0 = 0x00;
          [B] delay_ms(500);  //add this to make it off[/B]
 }
     
}

I'm writing the code in MikroC, and simulating it in Proteus using a PIC18F4553 device. The LED goes on, but does not flash. Am I missing something?
after PORTC.F0=0x00; U R NOT GIVING ANY DELAY. SO u cant see the led in OFF state since its OFF only for very few clock periods(i mean the clocks required to reach PORTC.F0=0xFF;)....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top