Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/29/01 10:00
Read: times


 
#12892 - RE: AT89C52 Serial Port
hi david,
well listen, obviously you don't have much experience on the 8x51 mcu.
the following program is very simple to understand because it is well structured unlike yours. now try to understand what it does before u even compile it on the pinnacle52.
i added some comments to ease your task:

; RESET

ORG 0000H
AJMP START
;
;***************************************
;
; INTERRUPTS: these are int addresses
;that u're not gonna be using
;
ORG 03H ;ext int0
RETI
ORG 0BH ;timer0 int
RETI
ORG 13H ;ext int1
RETI
ORG 1BH ;timer1 int
RETI
ORG 23H ;serial int
RETI
;
;***************************************
;
INITIALIZE: ;set up control registers
;
MOV TH1, #0FDH ;Set up for 9600 baud rate
MOV SCON, #01010000B ;Mode = 8 bit UART
MOV TMOD, #00100001B ;Sets Timer1 to 8 bit auto reload
MOV TCON, #01000000B ;Turns Timer1 on
RET
;
;***************************************
;
; Real code starts below.
;
;***************************************
; This routine transmits the value in ACC through the serial port.
;
SEND:
CLR TI ;Clear Timer1 Flag
MOV SBUF, A ;Transmit Byte: u should
;see whatever word was read from Port1
;on your oscilloscope
WAIT:
JNB TI, WAIT;Wait for transmission
;to be completed.
RET
;
;***************************************
;
START: ;program jumps to this point
MOV SP, #030H ;Set Stack to 30H
ACALL INITIALIZE ;Set up control
;registers
ORL P1,#0FFH ;Make Port 1 an input
;port
SETB P3.5 ;Make P3.5 an Input pin

LOOP:
JB P3.5, LOOP;Wait until P3.5 goes
;low: u need to pull this pin low in
;order to exit LOOP
; use a push-button for example

MOV A,P1 ;Read Port1
ACALL SEND ;Send Value to serial port
AJMP LOOP ;Go to LOOP(jump back to
;point labeled LOOP)
END ;End program

now u see, each time u pull P3.5 low the 89C52 reads port1 and transmit the word through the Txd pin.

happy programming and if u still have questions then do not hesitate.
let me know if it worked out.
mourad

List of 10 messages in thread
TopicAuthorDate
AT89C52 Serial Port            01/01/70 00:00      
RE: AT89C52 Serial Port            01/01/70 00:00      
RE: AT89C52 Serial Port            01/01/70 00:00      
RE: AT89C52 Serial Port            01/01/70 00:00      
RE: AT89C52 Serial Port            01/01/70 00:00      
RE: AT89C52 Serial Port            01/01/70 00:00      
RE: Serial Port... George            01/01/70 00:00      
RE: Serial Port... George            01/01/70 00:00      
RE: AT89C52 Serial Port            01/01/70 00:00      
RE: AT89C52 Serial Port            01/01/70 00:00      

Back to Subject List