Rules | Recent posts | topic RSS | Search | Register  | Log in

Bitbanging C sample Code

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers
Author Message
suvarna_mtech



Joined: 04 Oct 2008
Posts: 2


Post04 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


Post04 Oct 2008 18:03   Re: Bitbanging C sample Code

bit time = 1/baudrate
are you using interrupt for detecting the start bit?
check this link hope it helps

http://www.dnatechindia.com/index.php/Tutorials/8051-Tutorial/Bit-Banging.html
Back to top
suvarna_mtech



Joined: 04 Oct 2008
Posts: 2


Post06 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
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap