this is my code for serial communication using 8051 iam trying to send letter B on serial port but iam not getting any thig on heperterminal though all setting are ok .so not getting what the problem is.
ORG 000H MOV TMOD,#20H MOV TH1,#0FAH MOV SCON,#50H SETB TR1 MOV A,#'B' ACALL DELAY A_1: MOV SBUF,A H_1: JNB TI, H_1 CLR TI SJMP A_1 DELAY: MOV R0,#255 L1: DJNZ R0,L1 MOV R1,#255 L2: DJNZ R1,L2 RET end
Hi "LA p",
It's likely too late for the answer, nevertheless I want to tell you that there is NO "real" bug in your piece of code and it should work without problems. And it really works in the Keil debugger. Note: you must just realize that the sent character WON'T APPEAR IMMEDIATELY in the Serial Window after the instruction "MOV SBUF, A" has been carried out. The time of its appearance depends on Baud rate, so you must carry out quite a lot of 'idle' steps at H_1 ("JNB TI, H_1"). (You can insert a breakpoint on "CLR TI" and run the simulator at full speed). My advice: Commenting your code is a very good practice (I myself mostly write quite detailed comments) but in this case the code is very short, practically self explained and in fact described in your text above it. The only missing important information is the clock frequency used, therefore it's impossible for us to determine the Baud rate. You also haven't told us any particulars concerning the used "hyperterminal", its setup, etc. As to the code itself, I can't find any reason for the delay loops. In my opinion they are completely useless here (btw. only one register, either R0 or R1, might have been used).
To Erik Malund:
1."Anyhow one of the problems you have is that you are not aware of how TI works, you mix 'knowledge' of interrupt driven UART in with your polled routine."
2.another issue is that a timer does not drive the UART if it is not running
Ad 1) ??? Erik, I'm sorry, but I haven't noticed anything concerning interrupt driven UART in that code! What did you mean?
Ad 2) and what is "SETB TR1" then?
To Silly Saussage:
LED diode... ;-)
As to the term 'baud rate': 'Baud' [Bd] is a name of a unit named after Emile Baudot, 'rate' means a speed. In my opinion(!), the word 'baud' just specifies it closer and baud itself doesn't mean the same as the word 'rate'.
Best regards Eric
'Baud' [Bd] is a name of a unit named after Emile Baudot, 'rate' means a speed.
Eric,
Try using google and doing a define:baud
Far more often than not, you'll get something along the lines of 'unit of signalling speed' and 'number of bits per second'.
When I last got stopped by the police for speeding, they said I was doing 39MPH in a 30MPH zone, they didn't say I was doing 39MPH speed in a 30MPH speed zone.
Change that to 'if I were to get stopped by the police' ;)
But at least the definitions claiming "number of bits per second" should be ignored since that is a very bad definition.
View all questions in Keil forum