org 0h
main:
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 TH2,#0FDH
mov TL1,#0FDH
mov TL2,#0FDH
;Start Timer
setb TR1
Serial_Send:
;wait for last data to be
;sent completely
jnb TI,Serial_Send
;clear the transmit interrupt flag
clr TI
;Then move the data to send in SBUF
mov SBUF,A
Serial_Read:
;Wait for Receive interrupt flag
jnb RI,Serial_Read
;If falg is set then clear it
clr RI
;Then read data from SBUF
mov A,SBUF
mov p1,a
acall delay
jmp main
DELAY:
MOV R6 ,#0FFH
wait1:
MOV R7 ,#0FFH
wait3:
DJNZ R7,wait3
DJNZ R6,wait1
RET
end
ORG 0
AJMP BEGIN
ORG 40h
BEGIN:
MOV SCON,#01010000B ; (50H) Mode 1/Rec en
; bit 4 = REN receive enable
; bit 6 = mode 1. - 8 bit uart variable baud rate
MOV TH1,#0FDH ; Reload value for 9600 Bd @11.0592 MHz
MOV TMOD,#00100000B ; (21H) Gate1/Timer/Mode 2 / Gate0/Timer/Mode 1
; bit 5 = 8 bit auto reload for timer 1 (Mode2)
setb TR1 ; start timer 1
START:
JNB RI,START
CLR RI
MOV A,SBUF ;read incoming byte
MOV SBUF,A ;send it back
AJMP START
end
ehsanelahimirza said:in my book of 8051 by mazidi it is written that these capacitors may have a range from 1uF to 22uF. if i go with book then my circuit should work. but in data sheet also 0.1 or 1uF is mentioned, it is not said that above these capacitor will not work.
i m confused now.
#include <at89x51.h>
volatile char acceptext;
volatile bit status=0;
void IntSerial()Interrupt 4 using 1
{
Es=0;
RI=0;
status = 1;
acceptext = SBUF;
ES=1
}
Void inituart(void) // serial port initialization
{
SCON = 0x50; // uart in mode 3
TMOD = TMOD | 0X20; // timer 1 in mode2
TH1 = 0xfd ;// setting baudrate 9600 bps
TL1 = 0xfd;
ES=1 ; // enable serial interrupt
EA = 1 ; // enable global interrupt
TR1 = 1 ; // start timer 1 running
}
void sendchar(char datasent) // for sending one charater
{
SBUF = datasent;
while (!TI)
{;}
TI = 0;
}
void sendtext(char *text) //for sending text
{
char i=0;
while (text[i]!=0)
{
sendchar(text[i]);
i++;
}
}
Void main(void)
{
inituart();
sendtext("TRIAL 1");
}
after a long time i opened this website all of you guys have problem with PC and Micro Controller serial communication the little hint is re- check the baurd rate i had all these problems in my time what you r discussing here use 1200
- - - Updated - - -
after a long time i opened this website all of you guys have problem with PC and Micro Controller serial communication the little hint is re- check the baurd rate i had all these problems in my time what you r discussing here use 1200
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?