Hi all,
I know that there are quite a few sites explaining the sbit function, but with reference to the code below (which is using a timer) is the sbit setting bit 0 of port 2 as output? If no, which instruction is setting the port as output?
Also, is "out = ~out;" inverting the state of the output? (i.e. if the output is high, change to low and vice versa).
And the last question, in instruction "while(TF0 == 0); ", will the program stay looping in this same line until TF0 not equal 0 ?
Any help would be appreciated.
I know that there are quite a few sites explaining the sbit function, but with reference to the code below (which is using a timer) is the sbit setting bit 0 of port 2 as output? If no, which instruction is setting the port as output?
Also, is "out = ~out;" inverting the state of the output? (i.e. if the output is high, change to low and vice versa).
And the last question, in instruction "while(TF0 == 0); ", will the program stay looping in this same line until TF0 not equal 0 ?
Any help would be appreciated.
Code:
sbit out = P2^0;
void main(void)
{
TMOD = 0x0;
TH0 = 0xE1;
TL0 = 0XFF;
TF0 = 0 ;
TR0 = 1 ;
while(1)
{
out = ~out;
while(TF0 == 0);
TR0 = 0;
TH0 = 0xE1;
TL0 = 0xFF ;
TF0 = 0;
TR0 = 1;
}
}