Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me on ASM code for 8051 Serial Communication

Status
Not open for further replies.

singer06

Newbie level 1
Joined
Jul 10, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
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...

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
 

check following corrections

Code:
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 ------------------------------------> ;comment this line (no need)
        ;Start Timer
        setb TR1
        ret
     


;--------------------------------------------------> check this correction
serial_send :

mov SBUF,A  ;
Here: jnb TI,Here ;    
;-------------------------------------------------->
  clr TI     ;
  
  RET ; 

  END

hope your comments

regards
bassa
 

Hello can you help me with code on how to send AT command from an 8051 to a nokia phone
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top