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

How to Create UART with Software (not used SBUF) on 8051



 
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> How to Create UART with Software (not used SBUF) on 8051
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Author Message
winit_a



Joined: 16 Nov 2003
Posts: 17


Post15 Feb 2004 5:42   How to Create UART with Software (not used SBUF) on 8051
tags: uart 8051 c software uart 8051 8051 mcu with 3 uart uart 8051 p3.1 uart 8051 c

How to Create UART With Software?
My project Used 3 UART (normal have 1 UART with HARDWARE P3.0 and P3.1)

8051 MCU @ 11.0592MHz
How to Create UART used P2 or P1 to Interface RS-232
Back to top
View user's profile
pisoiu



Joined: 31 Dec 2002
Posts: 902
Helped: 24
Location: Romania


Post15 Feb 2004 11:58   Re: How to Create UART with Software (not used SBUF) on 8051
tags: uart implementation for 8051 in c xon xoff 8051 uart 8051 c software uart 8051 implement uart software in 8051 8051 xon xoff implementation 8051 uart with parity in c

Hi,
My opinion: it is damn hard. You will have to do it using interrupts, but 8051 is a relatively slow controller, its performance stays under 1mips at 11,0592mhz clock for clasic 8051 versions (1instruction cycle=12 clock cycle). More than one serial port implemented in software will eat almost all processor time, especially if you want to go up to 115200bps with those ports, or if you want to implement all possible parameters (6/7/8 data bits selecteble, 1/2 stop bits, parity odd/even/mark/space/none, flow control selectable xon-xoff/hard/none). My sugestion is to use an modified architecture 8051 from cypress, or to use a scenix microcontroller ( www.ubicom.com ). For scenix controller I can provide code for 8 uarts simultaneously. This if you want a software implementation. If yau want hardware, you can use max3100 (maxim).

Best,
Back to top
View user's profile
Ajay



Joined: 29 Feb 2004
Posts: 31


Post01 Mar 2004 0:10   Re: How to Create UART with Software (not used SBUF) on 8051

You could create one UART (in addition to using the SBUF) by using a dedicated timer and writing very fast code to rotate bit. On the incoming side (RXD), you must use an interrupt pin. When the interrupt comes, start your timers and read the pin status into carry, rotate and create your incoming bytes. Works well upto 9600 Baud (I have used it).

However, creating two MORE at the same time? Forget it. Even if you use two dedicated timers, the interrupt routines become so big that you will miss bits.

If you are looking for slow UARTs (1200 Baud or slower), then this technique works for upto 2 UART's. Keep in mind that you will give up all the three timers (one used for baud rate gen for SBUF, one for port 1 and one for port 2 timing) as well as both the interrupts.

So, better design is to use an ARM chip with two UART's (I have created 2 additional UARTs at 19200 Baud with an ARM) or use the Rabbit controller or some such thing.

Ajay
Back to top
View user's profile
beuch



Joined: 06 Jun 2001
Posts: 65
Location: France


Post03 Mar 2004 14:45   Re: How to Create UART with Software (not used SBUF) on 8051

Hi,

have a look to the attached file from Philips web AN.

AN446

bye



Sorry, but you need login in to view this attachment

Back to top
View user's profile
crazytnt



Joined: 02 Feb 2004
Posts: 8


Post03 Mar 2004 17:43   Re: How to Create UART with Software (not used SBUF) on 8051

It's very difficult.
Suggest using hardware.
Back to top
View user's profile
J_expoler2



Joined: 10 May 2003
Posts: 179
Helped: 19


Post03 Mar 2004 18:00   Re: How to Create UART with Software (not used SBUF) on 8051

Hi
i have some idea UART but send data only by using timer 0
bit T232 as TxD
MOV TMOD,#22H
MOV TH0,#70H
MOV TL0,#70H
SETB EA
SETB ET0
SETB TR1
;
;
;
;
function send data:
CLR T232 ;START BIT
SETB TR0
MOV R7,#8

TX_LOOP: RRC A
JNB TF0,$
MOV T232,C
CLR TF0
DJNZ R7,TX_LOOP
JNB TF0,$
SETB T232 ;STOP BIT
CLR TF0
JNB TF0,$
RET
it maybe help u
BR.
Back to top
View user's profile
fireplus



Joined: 31 Oct 2003
Posts: 195
Helped: 5


Post04 Mar 2004 3:29   Re: How to Create UART with Software (not used SBUF) on 8051

try that

[hr:5c6e3c7296]
Fire in the Wire :sm2:



Sorry, but you need login in to view this attachment

Back to top
View user's profile
Ajay



Joined: 29 Feb 2004
Posts: 31


Post08 Mar 2004 12:28   Re: How to Create UART with Software (not used SBUF) on 8051

J_expoler2 wrote:
Hi
i have some idea UART but send data only by using timer 0
bit T232 as TxD
MOV TMOD,#22H
MOV TH0,#70H
MOV TL0,#70H
SETB EA
SETB ET0
SETB TR1
;
;
;
;
function send data:
CLR T232 ;START BIT
SETB TR0
MOV R7,#8

TX_LOOP: RRC A
JNB TF0,$
MOV T232,C
CLR TF0
DJNZ R7,TX_LOOP
JNB TF0,$
SETB T232 ;STOP BIT
CLR TF0
JNB TF0,$
RET
it maybe help u
BR.


This is only good for transmitting. Problem comes when you try to receive as well. First of all, this method will NEVER work for full duplex operation unless you use two DIFFERENT timers.

Moreover, for receiving, you will need to use a hardware interrupt which will precisely start the timer at the right time and then will help shift the data. Again, this method is only good as a half duplex communication.

Another complexity comes from the fact that the interrupt routines become long and will cause problems by missing bits. Keep in mind that the error will accumulate over a period of time!

The best way is to use a chip which has more serial ports (ARM, uPSD from ST etc.)

Ajay
Back to top
View user's profile
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> How to Create UART with Software (not used SBUF) on 8051
Page 1 of 1 All times are GMT + 2 Hours


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS