Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

connecting two 8051 with bit banging UART

Status
Not open for further replies.

Keklja

Junior Member level 2
Joined
Nov 11, 2011
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,450
Hello, my project is to connect two 8051 and each of them have some led and buttons. Idea is to push button witch is connect to one 8051 and to turn on led or write something on lcd that is connected to other led. Master 8051 must have rx and tx pins free so on that controller pins p1.1and p1.2 have to be configured for communication with other (slave) 8051. Schematics (in proteus) is in attachment View attachment 8051.rar
 

Was there a question in there somewhere?
Sounds like a fun project, you'll need to set up a timer to interrupt at a specific frequency, ideally 16x that of what you want to send data at, this clock can then be used to determine your timing parameters, generate a start bit, look for this start bit at the other end by sampling your incoming signal at the 16x clock rate, when you detect the end of the start bit, count 8 clock cycles in and then sample the signal(at the middle of that bit because of the 8 count), that will give you bit 1, then count 16 clocks and sample again, do this for how ever many bits you are sending at a time and voilà you have received a byte. The same principals can be applied to the transmitter.

/Pheetuz
 

Was there a question in there somewhere?
Sounds like a fun project, you'll need to set up a timer to interrupt at a specific frequency, ideally 16x that of what you want to send data at, this clock can then be used to determine your timing parameters, generate a start bit, look for this start bit at the other end by sampling your incoming signal at the 16x clock rate, when you detect the end of the start bit, count 8 clock cycles in and then sample the signal(at the middle of that bit because of the 8 count), that will give you bit 1, then count 16 clocks and sample again, do this for how ever many bits you are sending at a time and voilà you have received a byte. The same principals can be applied to the transmitter.

/Pheetuz

That sound right but how do I write code (in c) for that? Im not that good programer. I need help with the code please
 

try to write code step by step you write code for you master and its interfaced i/os for example say write code for your keys. then go for that input to send your master communication pins. and checked it with your pc hyper terminal are you getting any data on not. then go for your slave programming for your leds and its action on received data from your master.
 

I think I can safely say that you arent going to get anyone here to write the code for you but there are an abundance of 8051 examples on the internet, you should be able to find out how to enable a timer by doing that and set it up to the speed that you want, that's your starting point, then you can use this timer to trigger an interrupt during the service routine of which you update the output port and sample the input port. Any time not spent in the ISR can be used for processing the bits you are receiving or updating you output shadow register.
No-one can teach you to write good C code, your going to have to get yourself a copy of K&R and learn as you do this project ... I doubt you will need many complex constructs to develop what you are suggesting at a basic level. Probably just need to learn about variables, loops and conditional statements, possibly (probably) pointers as well.

/Pheetuz
 

I think I can safely say that you arent going to get anyone here to write the code for you but there are an abundance of 8051 examples on the internet, you should be able to find out how to enable a timer by doing that and set it up to the speed that you want, that's your starting point, then you can use this timer to trigger an interrupt during the service routine of which you update the output port and sample the input port. Any time not spent in the ISR can be used for processing the bits you are receiving or updating you output shadow register.
No-one can teach you to write good C code, your going to have to get yourself a copy of K&R and learn as you do this project ... I doubt you will need many complex constructs to develop what you are suggesting at a basic level. Probably just need to learn about variables, loops and conditional statements, possibly (probably) pointers as well.

/Pheetuz

I already made one project with timer interupt and I get that. Problem is i dont understand this part with sampling input port and updating output port. And what is the K&R?
 


Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top