VTech Alphabert s Magic Readport User Manual Page 45

  • Download
  • Add to my manuals
  • Print
  • Page
    / 80
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 44
BM Dept., Govt. Engg. College, Gandhinagar Page 45
MOV TH1,#0FDh ;Count value for baud rate 9600
MOV SCON,#50h ;8 bit UART mode, REN enable
MOV P0,#00h ;Port P0 output port
SETB TR1 ;Start timer 1 to generated baud rate.
CHECK:
JNB RI,CHECK ; Check whether data byte is received or not
MOV P0,SBUF ; Display received data on port P0
CLR RI ; Clear RI flag
SJMP CHECK ;Repeat task
END
Program 2: Serial data reception using interrupt method:
In interrupt method, instead of checking RI flag continuously we use serial port
interrupt. When RI flag set, program will automatically jump to the location 0023h which is
vector location of serial interrupt. In this program we read port P1 continuously and display its
content on port P2.
ORG 00h
AJMP start
ORG 23h ;Location for serial interrupt
MOV P0,SBUF ; Display received data on port P0.
start: CLR RI
RETI ;Return from the ISR
MOV P1,#0ffh ;Make P1 output port
MOV P2,#00h ;Make P2 output port
MOV TMOD,#20h ;Timer 1, mode-2 ( auto reload mode)
MOV TH1,#0FDh ;Count value for baud rate 9600
MOV SCON,#50h ;8 bit UART mode, REN enable
MOV IE,#90h ; Enable serial interrupt and EA bit
SETB TR1 ;Start timer 1 to generated baud rate.
next: MOV A, P1 ; Read port P1
MOV P2,A ; Display content of port P1 on port P2.
SJMP next ;Repeat task
END
Program 3: Program at computer side:
Program for serial communication in “C” language is given here. Alternately we can use
hyper terminal or XTalk software for serial communication.
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define PORT1 0x3F8
/* Defines Serial Ports Base Address */
/* COM1 0x3F8 COM2 0x2F8 COM3 0x3E8 COM4 0x2E8 */
void main(void)
{
int c,ch;
outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */
outportb(PORT1 + 0 , 0x0C); /* Baud rate 9600 */
/* Set Baud rate - Divisor Latch Low Byte */
/* Default 0x03 = 38,400 BPS 0x01 = 115,200 BPS 0x02 = 57,600 BPS
Page view 44
1 2 ... 40 41 42 43 44 45 46 47 48 49 50 ... 79 80

Comments to this Manuals

No comments