singer06
Newbie level 1
Re: Receiving data through RS232 problem
hi,
i am continuing from the above post...i have used 8051 to communicate b/w PC and 8051....the data flow is from adc 0804 to microcontroller 8051 to the serial port to hyperterminal of PC...the asm code is as below ...but i cant see any output on hyperterminal screen...
hi,
i am continuing from the above post...i have used 8051 to communicate b/w PC and 8051....the data flow is from adc 0804 to microcontroller 8051 to the serial port to hyperterminal of PC...the asm code is as below ...but i cant see any output on hyperterminal screen...
Code:
cs equ P0.0 ;Chip Select P0.0
intr equ P3.2 ;INTR signal P3.2
adc_port equ P1 ;ADC data pins P1
org 0H
acall serial_init ;SET serial port
start: ;Start of Program
acall conv ;Start ADC conversion
acall read ;Read converted value
acall hex2ascii ;
mov A,R7 ;
ADD A,#30H ;
ACALL serial_send ;
MOV A,R6 ;
ADD A,#30H
acall serial_send ;send raw data to computer
MOV A,R5 ;
ADD A,#30H ;
acall serial_send ;
sjmp start ;
conv: ;Start of Conversion
clr cs ;Make CS low
clr wr ;Make WR Low
nop
setb wr ;Make WR High
setb cs ;Make CS high
wait:
jb intr,wait ;Wait for INTR signal
ret ;Conversion done
read: ;Read ADC value
clr cs ;Make CS Low
clr rd ;Make RD Low
nop
nop
nop
nop
nop
mov a,adc_port ;Read the converted value into A
setb rd ;Make RD High
setb cs ;Make CS High
RET ;
serial_init:
;Set timer 1 mode to 8-bit Auto-Reload
mov TMOD,#20H
;Enable reception
;Set Serial port mode to 8-bit UART
mov SCON,#50H
;Set baudrate to 9600 at 11.0592MHz
mov TH1,#0FDH ;
mov TL1,#0FDH ;
setb TI
;Start Timer
setb TR1
ret
hex2ascii :
// A/10 = Q1 ;
// A%10 = digit_1 ==> R7
MOV B,#0X0A ;
DIV AB ;
MOV R7,B ;
//A/10 =Q2 ;
// A%10 = digit_2 ==>R6
MOV B,#0X0A ;
DIV AB ;
MOV R6,B ;
// A/10 =Q3
// A%10 = diigit_3 ==> R5
MOV B,#0X0A ;
DIV AB ;
MOV R5,B ;
RET
// d3 = x/10
serial_send :
jnb TI,serial_send ;
clr TI ;
mov SBUF,A ;
RET ;
END