VTech Alphabert s Magic Readport User Manual Page 46

  • Download
  • Add to my manuals
  • Print
  • Page
    / 80
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 45
Lab Manual of Microcontroller & Interfacing Page 46
/* 0x06 = 19,200 BPS 0x0C = 9,600 BPS 0x18 = 4,800 BPS */
/* 0x30 = 2,400 BPS */
outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte
outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */
outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register */
outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS, and OUT2 */
printf("\nSerial Communication with microcontroller. Press ESC to quit \n");
do { c = inportb(PORT1 + 5); /* Check to see if char has been received */
if (c & 1) {ch = inportb(PORT1); /* If so, then get Char */
printf("%c",ch);} /* Print Char to Screen */
if (kbhit()){ch = getch(); /* If key pressed, get Char */
outportb(PORT1, ch);} /* Send Char to Serial Port */
} while (ch !=27);
/* Quit when ESC (ASC 27) is pressed */
}
Program 4 : Receive and store data in RAM using interrupt
;Program to receive data through serial port of microcontroller at the
;baud rate 9600. Store data from the RAM location 20h
;This program uses interrupt method for reception of data
start: ORG 00h
AJMP start
ORG 23h ;Location for serial interrupt
ACALL store
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
MOV R0,#20h ;Pointer to the RAM location
SETB TR1 ;Start timer 1 to generated baud rate.
next: MOV A, P1
MOV P2,A
SJMP next ;Repeat task
store: MOV A,SBUF
MOV @R0,A
INC R0
CLR RI
RET
END
Program 5: Receive and store data using polling (status checking)
;Program to receive data through serial port of microcontroller at the
;baud rate 9600. Store data from the RAM location 20h
;This program uses polling method.
ORG 00h
AJMP start
start: MOV TMOD,#20h ;Timer 1, mode-2 ( auto reload mode)
Page view 45
1 2 ... 41 42 43 44 45 46 47 48 49 50 51 ... 79 80

Comments to this Manuals

No comments