Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 12F675 on digital IO problem..

Status
Not open for further replies.

nirajb

New Member
Dear Friend,

i am starting on PIC first time. here is my code for blinking LED using timer0 on Hi-tech compiler (free version)
My question:
--> LED is blinking when GPIO is not assign first time in code...
but
--> LED is not blinking when GPIO is assign first time in code...

Here is sample code when GPIO is assign first time (LED not blinking)
Code:-
#include<htc.c>
char tick_count;
int delay;
void main()
{ // int start....
CMCON=0x07;
ANSEL=0x00;
TRISIO=0x00;
OPTION=0x84;
INTCON=0xA0;
TMR0=0x00;
GPIO=0x00; //This line is problem for me...
//int end
while(1)
{
if(tick_count>=50)
{
tick_count=0;
delay++;
switch(delay)
{
case 1:
GPIO=0x00;
break;

case 2:
GPIO=0xff;
delay=0;
break;

}
}
}
}

void interrupt x(void)
{
if(TOIE && TOIF)
{
TOIF=0;
TMRO=0;
++tick_count;
}
}


Note:= above code not working for me because of I int. GPIO before while..
but if you lable it then this code working...

can you help me.. ??
any reg. i forgot then please tell me...

Regards,
Niraj
 
more detail is here...

mikroC compiler also give same ...
my hardware:-
internal 4MHz osc.
Led +ve(Anode) connected with +5V supply with res. and Led -ve connected with Port pin.

Niraj
 
I could be wrong because your code is jumbled, but I believe you are missing one curly (end) bracket in the segment before your interrupt.

Check it with MPLAB.
 
Status
Not open for further replies.

Latest threads

Back
Top