Problem with LED blinking C code for PIC16f676

Status
Not open for further replies.

Suleman

Newbie level 2
Joined
Sep 28, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
> Hi, Im using a PIC for the first time (PIC16f676), I downloaded a hex file for an LED Blinking project from here:
blink a LED
and it worked perfectly, but then Itried writing my own program in C (MPLAB and HITEC C compiler), and it doesnt work, even though the circuit is the same for both the hex i downloaded and the program I made:

Code:
#include<htc.h>

__CONFIG(BGHIGH & UNPROTECT & BORDIS & MCLRDIS & PWRTEN & INTOSCCLKO & WDTDIS);
#define _XTAL_FREQ 4000000
void main()
{
TRISC=0;

for(;;)
{

PORTC=0x1f;
__delay_ms(500);

PORTC=0;
__delay_ms(500);

}

}

Any idea why it isnt working on the breadboard, even though it simulates pefectly in Proteus (ISIS)?
 

Re: PIC16f676 LED BLink!

hi,
verify the oscillator section of your code
 

Re: PIC16f676 LED BLink!

By oscillator section do you mean the __CONFIG() Directives, or the Oscillator frequency, because both of them seem to be correct...The PIC 16f676 has an internal 4Mhz Oscillator
 

Re: PIC16f676 LED BLink!

Wondering how you simulated in Proteus for pic16f676. I have simulated some pics in Proteus all working fine. but not pic16f676.

It reads
[COFF]could not load source file 'startup.as'.

can i know the version of proteus and hitech compiler u are using??
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…