Hi guys, Here is the situation I've 89c51 microcontroller board which I want to connect with PC as well as GSM but as everybody knows it(8051) has only one UART so one solution is try using 87xx or 83xx series of controller but that means I'll have to change my programmer. So what I'm thinking is I'll use simple mux/demux for Tx/Rx of 8051. I want to know will it be o.k.? Can simple AND or OR gates can handle data rate of 9600bps?
Thank you very much in advance.
Well guys the assembly I've designed was working fine till I tried to receive the data through it i.e. My board(at89c51) is still able to transmit data to 2 devices alternatively however when I multiplexed the transmit lines of 2 devices to connect to receive line of (at89c51) , it doesn't work. please provide your suggestions anyway will update if I find some solution
"when I multiplexed the transmit lines of 2 devices to connect to receive line of (at89c51) , it doesn't work"
So you've done it wrong!
With no details of exactly what you have done, or exactly how it "doesn't work", it is obviously impossible to say exactly where it's wrong!
One thing: how do you ensure that you don't switch the multiplexer in the middle of a character?
My 2 PCs (which are connected to my microcontroller) don't communicate simultaneously so I've ORed their transmit pin to connect to receive of microcontroller
After the RS232 receivers, of course...?!
We have a similar situation and have implemented an analog switch to switch between the two ports rather cheap way to solve it but with a small possibility of missing data if not coded right :)
ya after MAX232 i.e. when signals are TTL level I guess my switching occurs properly but serial initialization routine can't be activated properly have a look
#define R 1 #define G 0 . . . Long_Delay(200); Select_Serial = R; LongDelay(); Init_Serial(); Xmit_Static_Char('R'); P0 = 0x01; LongDelay(); Select_Serial = G; LongDelay(); Init_Serial(); Xmit_Static_Char('G'); P0 = 0x02; LongDelay(); Select_Serial = R; Init_Serial(); Xmit_Static_Char('R'); P0 = 0x01; LongDelay(); Select_Serial = G; LongDelay(); Init_Serial(); Xmit_Static_Char('G'); P0 = 0x02;
Here I can see R(1st terminal) G(2nd terminal) and R(1st) but that also sometimes then nothing but P0 shows LED status correctly as 0x01,0x02,0x01,0x02 etc.
That would be good option but my problem is I want switching to be handled by uC according to command comes to it Anyway Thanks for sharing your opinion
It's fairly pointless posting code with all the important bits missing!
What does Select_Serial do? What does Init_Serial() do? What does Xmit_Static_Char() do?
Where is serial reception handled?
Select_Serial is pin 3.2 to select which serial line to select (uC to terminal1 or uC to terminal2) Serial_Init initialize serial port i.e. TMOD 20h,SCON 50h etc. Xmit_Static_Char transmit a character. and reception is handled on hyperterminal on pc
"Select_Serial is pin 3.2 to select which serial line to select (uC to terminal1 or uC to terminal2)"
Does it work? Have you tested that the hardware does actually correctly route the signals?
"Serial_Init initialize serial port i.e. TMOD 20h,SCON 50h etc."
Again, does it work? Have you tested that the hardware is actually correctly configured to the correct baud rate, etc?
"Xmit_Static_Char transmit a character."
Yet Again, does it work? Have you tested that that it actually transmits the correct character?
"reception is handled on hyperterminal on pc"
Now I'm confused! In which direction is this multiplexing occurring?!
Why do you repeat this for every single transmitted character?!
Yes Andy the configuration i.e. H/W and S/W are working just fine. I am using these settings for other programs. Even switching is working perfectly as I can see status on port 0 with LEDs and For that initialization every time : At first I didn't use it but as that program didn't work I thought because of delay serial initialization may get hampered so I'm doing it every time anyway that way it won't cause any harm except little more machine cycles.
I guess I'm doing some stupid mistake I'll have to rectify it
Can anybody let me know what should following programing do? Is main in keil is reentrant? even with for loop following pogram work infinitely
//program to transmit a chaaracter #include<reg51.h> sbit Select = P3^2; void Delay(void); void main(void) { int i; SCON = 0x50; TMOD = 0x20; TH1 = 0xFD; TR1 = 1; for(i=0; i<21; i++) { Select = 0; SBUF = 'p'; while(TI == 0){} TI = 0; P2 = 'p'; Delay(); Delay(); Delay(); Delay(); Delay(); Select = 1; SBUF = 'q'; while(TI == 0){} TI = 0; P2 = 'q'; Delay(); Delay(); Delay(); Delay(); Delay(); } } void Delay(void) { unsigned char i; for(i=0;i<=200;i++) {} return; }
Is main in keil is reentrant This has nothing to do with Keil. main is 'reentrant' in the sense that it is entered after each reset, but in no other respect.
if you do not have an unbreakable loop in in your program will just 'overflow' at the end of main().
This is EMBEDDED and in EMBEDDED you do not exit from (the root) main(). ONLY if you have code with a main() that call code with a main() (a very construed construct) could you have a returning main().
Erik
Then why would above program work infinitely instead of only 21 times it transmits p and q infinitely