Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

software uart

Status
Not open for further replies.

baftab

New Member
i got this code from a site, but i cant assemble it in keil
which assembler whould i use??
or is there some fault with the code itself??
the '*' are giving some problem

"djnz r1,*" for instance



TXD EQU P1.0 Transmit on this pin
RXD EQU P1.1 Receive on this pin
* The serial baud rate is determined by the processor crystal, and
* this constant which is calculated as: (((crystal/baud)/12) - 5) / 2
BITTIM EQU 45 (((11059200/9600)/12) - 5) / 2
*
* Transmit character in A via TXD line
*
putc CLR TXD Drop line for start bit
MOV R0,#BITTIM Wait full bit-time
DJNZ R0,* For START bit
MOV R1,#8 Send 8 bits
putc1 RRC A Move next bit into carry
MOV TXD,C Write next bit
MOV R0,#BITTIM Wait full bit-time
DJNZ R0,* For DATA bit
DJNZ R1,putc1 write 8 bits
SETB TXD Set line high
RRC A Restore ACC contents
MOV R0,#BITTIM Wait full bit-time
DJNZ R0,* For STOP bit
RET
*
* Receive a character from the RXD line and return in A
*
getc JB RXD,* Wait for start bit
MOV R0,#BITTIM/2 Wait 1/2 bit-time
DJNZ R0,* To sample in middle
JB RXD,getc Insure valid
MOV R1,#8 Read 8 bits
getc1 MOV R0,#BITTIM Wait full bit-time
DJNZ R0,* For DATA bit
MOV C,RXD Read bit
RRC A Shift it into ACC
DJNZ R1,getc1 read 8 bits
RET go home


is this workable??
 
I Suppose this code is for a 8051 Micro controller, right?

a simple question, why don't you use the hardware UART.. ?
 
ikalogic said:
I Suppose this code is for a 8051 Micro controller, right?

a simple question, why don't you use the hardware UART.. ?

Go to the back of the class! :p

You've not being paying attention, he has another thread asking about dual UART's.
 
the hardware uart is already being used
am interfacing a rfid reader and my pc to the controller

i need an extra serial port...
i knw there are controllers available with 2 uarts, but i cant find them here...in my city...


so..?? which assembler should i use???

i think
djnz r1,*

means as long as r1 is not zero, keep on looping??
right??

keil assembler is not assembling

NOW Nigel...some help??
 
lol yeh...or they might be afraid to come out and show that they know something abt 89c51...they'll be ridiculed at

yeh...am not sure abt india, but in pakistan latest ics are not available..somethin to do with import restrictions on electronics equipments

we get the used ones and old ones :s

i couldnt find a single controller with 2 uarts here :S
no fair!!!
 
Status
Not open for further replies.

Latest threads

Back
Top