Back to the 2021 paper

Module 5: External Communication Interface

20217m

Write a program for 8051 to transmit "WELCOME TO INDIA" at the display connected to port 1 at 9600 baud for external crystal frequency of 11.0592 MHz.

Worked SolutionAI Assisted

Program to transmit "WELCOME TO INDIA" at 9600 baud, 11.0592 MHz, display on port 1 (serial transmission example)

Baud 9600 with 11.0592 MHz → Timer 1 mode 2, TH1 = 0FDH, SMOD=0 → 9600. Mode 1 (8-bit UART). Assume display is serial via TXD or port 1 is shown after reception - here we transmit via SBUF repeatedly.

; 8051 Assembly - Transmit string via serial Mode 1 at 9600 baud
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN: MOV TMOD,#20H   ; Timer1 mode2 auto-reload
      MOV TH1,#0FDH   ; 9600 baud @11.0592MHz
      MOV TL1,#0FDH
      MOV SCON,#50H   ; mode1, 8-bit, REN=1
      MOV PCON,#00H   ; SMOD=0
      SETB TR1        ; start timer1
      MOV DPTR,#MSG
NEXT: CLR A
      MOVC A,@A+DPTR  ; fetch char
      JZ STOP         ; 0 terminator end
      ACALL TRANSMIT
      MOV P1,A        ; also display on port1 as per question
      INC DPTR
      SJMP NEXT
STOP: SJMP STOP
TRANSMIT: MOV SBUF,A
WAIT:   JNB TI,WAIT
        CLR TI
        RET
MSG: DB "WELCOME TO INDIA",0
END

C (Keil) alternative:

#include <reg51.h>
void uart_init(){ TMOD=0x20; TH1=0xFD; SCON=0x50; PCON=0x00; TR1=1; }
void tx(char c){ SBUF=c; while(!TI); TI=0; P1=c; }
void main(){ uart_init(); char *s="WELCOME TO INDIA"; while(*s) tx(*s++); while(1);}

Calculation: Baud = (2^SMOD/32)(Fosc/12/(256-TH1)). With TH1=FDH (253), Fosc=11.0592M → (1/32)(11059200/12/3)=9600. Error 0%.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.