Discussion Forum

Serial window 1

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
javaid iqbal
Posted
2-Nov-2003 07:18 GMT
Toolset
C51
New! Serial window 1
I am using microvision2 (UV2)environment.
when i use the following code from examples(given by keil) i see "hello world" in the serial window, when i use degugger.

#include <REG52.H>
#include <stdio.h>
#ifdef MONITOR51
char code reserve [3] _at_ 0x23;
#endif

void main (void) {

#ifndef MONITOR51
SCON = 0x50;
TMOD = 0x20;
TH1 = 221;
TR1 = 1;
TI = 1;
#endif

while (1) {
printf ("Hello World\n");
}
}

But when i run my code written in assembly(shown below) does not give any output on serial window.
org 00
mov scon,#52h
mov tmod,#20h
mov th1,#221
setb tr1
setb t1
loop: mov A,#1
mov SBuf,A
jmp loop
end

Pl point me my mistake. suggest remedial measures.
Read-Only
Author
Stefan Duncanson
Posted
3-Nov-2003 11:41 GMT
Toolset
C51
New! RE: Serial window 1
You need to wait for TI to go true before loading SBUF. You would also probably be better to use a printable character rather than 1.

In 'C':

while(1)
{
while(!TI);
TI=0;
SBUF='A';
}

Stefan
Read-Only
Author
javaid iqbal
Posted
5-Nov-2003 04:22 GMT
Toolset
C51
New! RE: Serial window 1
thanks stefen, it solved my problem

Next Thread | Thread List | Previous Thread Start a Thread | Settings