??? 06/09/09 20:27 Read: times |
#165959 - transmit/recieve character by using 8051 and USART |
Hi ,for everyone ,I'm new here .
I working with some kit that use 8051 that has connection by USART(8251) and connecttion with PC by protocol RS-232c ,I want to recieve/send data by using Windows program HyperTerminal (I never work with it till now) I wrote some code on Assembly(I'm not such a good programmer in Assembler) in program my Usart already ready to send and recieved data and translate it to ASCII and viceversa to binary. but how i send data from terminal (from hyperterminal) are the any command I need to write, maybe I have mistakes in code you see that I must fix, how I continue my program? code is..: org 100h command: mov dptr,#0ff17h ;address for controll word for 8255(programable port) mov a,#89h ; the value of word(mode,port out,port in) movx @dptr,a ; send the word to 8255 mov dptr,#0dd1bh ; address of 8254(timer/counter) mov a,#36h ; value for counter movx @dptr,a ; send it to 8254 mov dptr,#0ff18h ; the address of Port0 in 8254 mov a,#14h ; the value for devider the clocking (6.144Mhz/20) movx @dptr,a ; mov a,#0h ; movx @dptr,a ; mov dptr,#0ff1dh ;address of Usart mov a,#0eeh ; value for Mode instruction: movx @dptr,a ; send the Mode instruction mov a,#37h ;Command Instruction for Usart(8251 movx @dptr,a ;send a command instructio recieve: mov dptr,#0ff1d ;address of Usart movx a,@dptr ;set value that Usart has to Accomulator jnb acc.1,recieve ;checking if bit not set ,if not Usart not ready recieve data,so it's return to recieve lcall BIN2ASC mov dptr,#0ff1ch ;if it ready recieve data it's located in address 0ff1ch movx a,@dptr ;mov it to Accumulator mov b,a ;store it in B send: mov dptr,#0ff1dh ;address of Usart movx a,@dptr ;check if usart ready to send data jnb acc.0,send ;by checking bit ,if not jump back to label send lcall ASC2BIN mov dptr,#0ff1ch ;if it ready recieve data it's located in address 0ff1ch mov a,b ;get data back to a movx @dptr,a ;send it out mov dptr,#0ff14h ;get address of portA (leds ,7-Seg) movx @dptr,a ;send a data to it sjmp recieve ASC2BIN: ;Convert from ASCII to Binary MOV A,R2 ;Inputs: R2,R3 LCALL BIN ;Output: A SWAP A ;R2 - M.S.D R3 - L.S.D MOV R2,A MOV A,R3 LCALL BIN ADD A,R2 RET BIN: CLR C SUBB A,#3AH JNC BIN2 ADD A,#0AH RET BIN2: ADD A,#3 RET BIN2ASC: MOV R4,A ;Convert from Binary to ASCII SWAP A ;Input: A LCALL ASC ;Outputs: R2,R3 MOV R2,A ;R2 - M.S.D R3 - L.S.D MOV A,R4 LCALL ASC MOV R3,A RET ASC: ANL A,#0FH CLR C SUBB A,#0AH JNC ASC2 ADD A,#3AH RET ASC2: ADD A,#41H RET end |
Topic | Author | Date |
transmit/recieve character by using 8051 and USART | 01/01/70 00:00 | |
Be sure your 8251 is fast enough | 01/01/70 00:00 | |
conver ASCII to bin and viceversa and interface | 01/01/70 00:00 | |
translate ASCII to binary ? [edited] | 01/01/70 00:00 | |
65 base 10 = 41 base 16 | 01/01/70 00:00 | |
Corrected! | 01/01/70 00:00 | |
binary to hex | 01/01/70 00:00 | |
Text representation of numbers | 01/01/70 00:00 | |
connection with HyperLink | 01/01/70 00:00 | |
unplug and plug | 01/01/70 00:00 | |
Question about Polling method for send recieve data | 01/01/70 00:00 | |
yes, and no![]() | 01/01/70 00:00 |