electronics forum

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
Author Message
winit_a



Joined: 16 Nov 2003
Posts: 17


Post15 Feb 2004 4:42   

uart xoff implementation


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
pisoiu



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


Post15 Feb 2004 10:58   

timers t232


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
Ajay



Joined: 29 Feb 2004
Posts: 31


Post29 Feb 2004 23:10   

8051 uart even 7 1


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
Google
AdSense
Google Adsense




Post29 Feb 2004 23:10   

Ads




Back to top
beuch



Joined: 06 Jun 2001
Posts: 65
Location: France


Post03 Mar 2004 13:45   

microcontroller sbuf


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
crazytnt



Joined: 02 Feb 2004
Posts: 8


Post03 Mar 2004 16:43   

uart implementation 8051 asm


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



Joined: 10 May 2003
Posts: 179
Helped: 19


Post03 Mar 2004 17:00   

uart implementation in 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
fireplus



Joined: 31 Oct 2003
Posts: 195
Helped: 5


Post04 Mar 2004 2:29   

80c51 software uart


try that

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



Sorry, but you need login in to view this attachment

Back to top
Ajay



Joined: 29 Feb 2004
Posts: 31


Post08 Mar 2004 11:28   

xon xoff 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
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
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 + 1 Hour
Similar topics:
How to create plane wave not aligned with axis? (1)
SBUF in 8051 (3)
help on Serial Communication using software not UART (5)
Software UART for 8051 Using Embedded C (1)
Help: How to deal with the IOs that are not used? (8)
to read from sbuf in 8051 (1)
U1RXREG with UART not being on? (1)
how to implement soft Uart on 8051 (2)
how to create a C code file for 8051 (5)
sending via 8051 uart -help me with the codes (2)


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