if(T01F) T01F=0;
The code:A clumsy way of doing it. And it will only obscure the code. It seams like T01F is already defined as a bit. So then it is correct to write in C
Which C compiler do you use Ericyeoh? The 16f84 is old, and the C compilers has evolved a lot since the the 16f84 chip was relased. So if your code is old, it may be somwhat out of date.Rich (BB code):if(T01F) T01F=0;
if(intcon & (1<<T01F))
#define T01F 2
if(T01F)
{
T01F=0;
}
if(2)
{
2=0
}
Hi,If T01F is bit 2 of the intcon register it would have been defined as equal to 2.
I.E.so the statementRich (BB code):#define T01F 2
would be nonsense and should not compile since you are effectively sayingRich (BB code):if(T01F) { T01F=0; }
Rich (BB code):if(2) { 2=0 }
if(INTCON.2)
{
INTCON.2=0;
}
True but in the context of the original question, for the codeHi,
In some compilers, eg. mikroC, T01F is not predeclared as 2, rather as INTCON.2, so in such circumstances, the code is correct.
So the code would stand as:Hope this helps.Rich (BB code):if(INTCON.2) { INTCON.2=0; }
Tahmid.
void interrupt(void)
{
if(intcon & (1<<T01F))
{
Clear_bit(intcon, T01f);
}
}
by Jake Hertz
by Jake Hertz
by Robert Keim
by Jake Hertz