04-30-2009 08:08 PM - edited 04-30-2009 08:09 PM
Hi, Everyone. I have a problem when comunication Labview with AT89S51 microcontroler through COM Port. When I send a character ( example sent "a" ) from write buffer in write VISA, but on Read buffer in read VISA don't display correct that character ( not "a" ).
Would you please check and help me this problem. Thanks you. Funny!
this my code on AT89S51 and code labview.
AT89S51:
org 0h
jmp init
org 30h
init:
mov scon, #01010000b ; Mode 1
mov tmod, #00100000b ; Timer 1 mode 2
mov th1, #0f9h ; baund rate 9600 bps( crystal 12 MHz)
setb tr1
clr ri
clr ti
start:
jnb ri, $
clr ri
mov a, sbuf
mov sbuf, a
jnb ti, $
clr ti
jmp start
04-30-2009 08:13 PM
Can't open your code (I only 8.2.1 at work), but a couple of ideas occur to me:
1) Check all the settings (baud rate, etc).
2) Check whether both are sending/receiving same endian order.
3) Check ASCII code and see what you are getting vs. what you sent.
I usually like to write out what I sent in both hex and binary and do the same with what I read to see if there is anything obvious.
04-30-2009 08:53 PM
Thanks MattBradley!
I used default 8bit data, 1bit stop. I attachment the pictures code and error. Could you please see again.
04-30-2009 11:18 PM
05-01-2009 03:09 AM
Hi, Dennis Knutson.
I moved #0101000b to SCON register, mean set SCON.6 and SCON.4 => selected mode 1 of Serial port operates. In this mode, 10 bits are transmitted on TXD or received on RXD. These consist 1 start bit, 8 data bits, 1 stop bit. I thinks my Labview program not good ( wrong). But I don't know where it wrong. I selected "hex display" follow you but it don't have any difference. Now I don't have any idea to do this project continue. Could who help me please. Thanks.
05-01-2009 05:19 AM
Download this document http://www.atmel.com/dyn/resources/prod_documents/DOC4316.PDF And read section 2.13. Pay attention to details . I can tell now that there is something wrong with your baudrate generation. Are sure you can generate a 9600 baudrate with a 12MHz osc and timer 1. Also did not like your Labview test program. You do not need those frames at all. And I also do not hope you are running with the continuous run button. Go to find examples and then search for serial. Then select the "Advanced Serial Write and Read.vi" If you modify it please use the save as option so other may use it after you. But nice to see some real assembler coding again
Here is some useful tips for the Labview beginner (we have all been there some time)
1)Then starting a new Labview session enable context help (Ctrl+h). Do not be afraid to use the detailed help option
2)Then stuck, go to help in the toolbar then select find examples
05-01-2009 06:33 AM - edited 05-01-2009 06:35 AM
Hi, Coq rouge happy to see you again.
I read a ducument about 8051 by mother stongue not yet read English, In there written with crystal 12MHz generate 9600 baud rate by timer 1 will have error 7%. I thought it still use ok. I'll change it as 11.0592 MHz. You want to say in my Labview program don't need use "Flash Sequence Structured"? I teach myself Labview so very slowly. Hope receive many help from you and everyone in there. Thanks you, have funny. See you late.
05-01-2009 06:46 AM
05-01-2009 07:10 AM
And it seems you did not do the simple task of changing to hex display.
If you don't think your LabVIEW program is correct, use one of the shipping examples or try the windows porgram hyperterminal. Hyerterminal is an easy check. If your text is garbled there, you know you have something wrong on the micro end (and I strongly suspect you do).
05-01-2009 07:58 PM - edited 05-01-2009 08:04 PM
Hi, I still use crystal 12 Mhz to generate 4800 baud rate ( moved #0f3h to th1). I changed to " Hex display" follow Dennis knutson. I used "Serial Write and Read Basic.vi" or "Advanced Serial Write and Read.vi" of the examples. All things I did still have error. I never use Hyerterminal to check RS - 232 so I don't know use it. And I can't see the wrong in my micro, could you say me it? Have when my hardware wrong? But I think it still good when see error.
This errors appear in my test