Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm looking into using Atmel's 2051 microcontroller with an Xbee and a HC-05 Bluetooth module, the micro however has only one serial connection and no possibility for expandability with memory-accessed peripherals. Is this doable or do I have to choose only one of the two?

share|improve this question
2  
An Atmel's what? –  Ignacio Vazquez-Abrams Apr 9 at 2:23
    
Sorry, I got the numbers wrong. –  Sanuuu Apr 9 at 3:19
add comment

2 Answers 2

up vote 2 down vote accepted

Use/find/implement your own Arduino style software-serial library for slow baud-rate serial comms to one of the devices, and use the hardware UART (serial) to the other one.

You could even do software serial for BOTH bluetooth and Xbee if data rates are kept low, and you dont have any crazy hard-realtime system (higher priority control) which may cause loss of data too often.

share|improve this answer
    
This. +1. Right here. Just borrow a couple of other pins on the controller and away you go. –  Sean Boddy Apr 9 at 5:02
    
I don't know how difficult it is to adapt Arduino code to run on 2051, but here's a library that apparently runs quite fast: the AltSoftSerial library, as recommended in this post: arduino.stackexchange.com/questions/854/…. –  gwideman Apr 9 at 5:16
2  
No need for Arduino code (Excessive bloat...) implenting a "soft serial port" is pretty simple if you are at all good at programming and carefully read through and understand the very basics RS-232 communication. Although I must admit, transmit is MUCH simpler to code than Receive. It should all be interrupt based. I communicate to serial peripheral on ATtiny devices without a USART port all the time. –  Kurt E. Clothier Apr 9 at 5:34
    
yeah, bit-banging is pretty damn easy, with nice and neat use of ISRs, I agree with @KurtE.Clothier The data rate should be kept as low as possible though to reduce errors. Maybe test at higher rates if you want, but expect failures in strange places –  KyranF Apr 9 at 6:55
add comment

Yes, You can use both. You might want to look into multiplexers. You can buy dual multiplexers. Depending on the sort of IC you use, it will normally have one input to connect your microcontroller to and two outputs. Or a long way could be to build your very own perhaps using high speed transistors or even mosfets. Although using an IC is recommended

share|improve this answer
1  
Another option is to use software (ie "bit-banged serial") to run the serial port. –  Eric Gunnerson Apr 9 at 3:47
    
@EricGunnerson, that would be one channel right? –  David Norman Apr 9 at 4:03
    
You can make it run for multiple devices over a single port using the bit banging method, provided that device being controlled is sophisticated enough to have to get properly addressed, using a name header or something. Not sure exactly how well the Xbee will tolerate listening to garbage intended for the bluetooth, but it might be able to behave itself. –  Sean Boddy Apr 9 at 5:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.