| Author |
Message |
suvarna_mtech
Joined: 04 Oct 2008 Posts: 2
|
04 Oct 2008 12:58 Bitbanging C sample Code |
|
|
|
Hi,
I am using P89C61X2 controller.
I want to connect one serial interfacing device to controller.
I am connecting it through bit banging.
I am not able to put time out, if the device not responds me.
Please help me out.
I am connecting device with 19200 bps,
I am confuse my used bit time is OK or not.
If my device is disconnected, my program is not timed out.
Controller remains in the loop
|
|
| Back to top |
|
 |
amol_shah
Joined: 21 Apr 2008 Posts: 97 Helped: 12 Location: Nasik, Mumbai
|
|
| Back to top |
|
 |
suvarna_mtech
Joined: 04 Oct 2008 Posts: 2
|
06 Oct 2008 4:59 Re: Bitbanging C sample Code |
|
|
|
Hi,
Thanks for the help.
I am not using interrupt.
Here is the code
BRXD = 1; //This is port pin which i'm using as receive
while(BRXD); //When data receives, Receive Pin goes low. Here i'm waiting for bit to receive. I am confuse how i put timeout here. I want this to timeout if data not receives in specified time interval
Bit_Time(BIT_TIME/2); //Wait 1/2 bit-time to sample in middle
for(; i < 8; i++) // Send 8 bits to the I2C Bus
{
inbyte = inbyte >>1;
Bit_Time(BIT_TIME);
if(BRXD)
inbyte |= 0x80;
else
inbyte &= ~(0x80);
}
return inbyte;
|
|
| Back to top |
|
 |