Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

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++)
;
}
 

millwood

Advanced Member level 3
Joined
Jul 2, 2009
Messages
734
Helped
80
Reputation
164
Reaction score
35
Trophy points
1,308
Activity points
5,088
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.
 

rajudp

Advanced Member level 2
Joined
May 27, 2006
Messages
644
Helped
123
Reputation
246
Reaction score
96
Trophy points
1,308
Location
India
Activity points
4,055
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.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top