Home - Search - Members
Full Version: 8051 serial communication
ashishdaga
May 11 2008, 12:24 AM
CODE:
here is my sample code for serial communication
org 00h
sjmp 30h

org 30h
start:
mov tmod,#20h
mov th1,#0fdh
mov scon,#50h
setb tr1
ag:
jnb ri,$
mov a,sbuf
clr ri
inc a
mov sbuf,a
jnb ti,$
clr ti
sjmp ag
end


baud rate is 9600 1stop bit and no parity

this works fine i.e when i send a 1 to the microcontroller from the pc
microcontroller increments and sends me a 2.i checked this in advanced serial port monitor.
http://www.aggsoft.com/serial-port-monitor.htm

when i replace inc a with mov a,#07 then it shows no transmission from microcontroller side.what could be the problem

is there any other gud software for checking my serial data???
help me urgently??
pdi33
May 11 2008, 4:26 AM
hi ashish,
the problem with ur code is about the way the PC communicates in. Well, it does not communicate in hex or decimal. in fact it can only recognize ASCII codes. So in the first case when u send say 1 to the microcontroller, the value that ur accumulator is actually receiving is 31h (ascii for '1'). this is then incremented i.e. it takes the value 32h and sends back to PC which recognises it as character '2'. But in the second case( where u found a problem), u r sending a fixed value 07h which is recognised as a special command (audible bell in this case) so u are not seeing any characters on the PC. try sending say 37h and u will get character '7' on the screen.

u can also send/receive bytes on the hyper terminal for checking ur serial hardware communication. just take care that the settings on baud rate etc. match ur microcontroller settings.
ashishdaga
May 11 2008, 4:33 AM
thanks a lot for replying will chk that soon
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007