Thank you for your reply but i do tried for a long time.
and here is the circuit diagram
http://www.ee.cuhk.edu.hk/~s017281/uart.gif
can anyone help me ?
I think you would have an easier time if you added the address/data
bus demultiplexer so that you could put A0..2 directly into the memory
map though it could work as you have it but it requires extra software
and execution time. I would write to P0 and P3 byte wide rather than
trying to set/clear the individual bits or is that not possible since
P3 also has the serial in and out data? If it were mine, I'd move
a0..2 to the P0 port so I could write byte wide. Pay close attention
to the interface to the UART to make certain the 'control' bits
(a0..2,rdn,wrn) are happening at the right time.
Is CEN tied to ground? The schematic doesn't show a junction where
ground crosses the CEN/resistor wire. Since it isn't a 'T' junction, I
assume it isn't tied even though it should be.
The system is further complicated in that you need to poll the UART to
find out if it needs attention. It would be much simpler to use
interrupts so the hardware does a little of the work for you rather
than having to write polling software (always a pain).
Keeping the address bits in order would be nice also so that it
increments in the same sequence as the P3 port.
I don't see a capacitor on the reset line of either the processor or
the UART. Are you certain they are in fact reset?
I added a code fragment of the serial interrupt for 8051 for a project
of mine from many years ago. You'll need to define the memory
locations of HEADOUT, TAILOUT and the like but it does work correctly
though it had 2k of external RAM for the input and output queues.
;**************************************************************
;* Serial Interrupt *
;**************************************************************
ORG $0023 ;hardware address of serial port
interrupt
JMP SERINT ;
other code