Problem with programming 12f675 in Hi Tech C compiler

Status
Not open for further replies.

anuphr

Newbie level 6
Joined
Aug 5, 2009
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,360
im using 12f675 ..with internal clock.. i am just tring to blink the led
.. but im not getting the result..plzz help me if u have a DEMO code in c.i amusing hi tech c compiler,, source code is in c...

this is the code i have used ..but not giving the result....


#include <htc.h>

#define _XTAL_FREQ 4000000 // oscillator frequ
ency for _delay()

// Config: ext reset, no code protect, no brownout detect, no watchdog,
// power-up timer enabled, 4MHz int clock
__CONFIG(MCLREN & UNPROTECT & BORDIS & WDTDIS & PWRTEN & INTIO);

void delay_ms(long );


void main()
{



TRISIO = 0b001010; // configure GP1 (only) as an output

// Main loop
while(1)
{
// turn on LED on GP1
GPIO1 = 1;


delay_ms(1000);
delay_ms(1000);

// turn off LED on GP1
GPIO1 = 0;

delay_ms(1000);
}
} // repeat forever
}
void delay_ms(long ms)
{
long i;

while (ms--)
for (i=0; i < 330; i++)
;
}
 

12f675 led

you should re-read the datasheet and see what the gpio ports are set to when it is powered up.

my experience is that you only start to program a mcu after you have read the datasheet at least 50x.
 

12f675 c code

check your fuse settings, some compilers will use osccal value automatily ie call 0x3ff in this case. give the osccal value while programming retlw value at 0x3ff
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…