Komunikasi Serial RS232 dengan Periperal Lain…

Program ini adalah project akhir mata kuliah Computer Architecture n Interface

buat ngetest apa yang di kirim oleh komp / periperal lain seperti Microcontroller.

program ini mengecek data secara polling…di COM port 1 yang alamat defaultnya adalah

0x03F8H……di tulis dengan bahasa C..dan udah tertested dengan BasicStamp n AVR16.

Hasil ProgramHasil Program pada saat runtime….

ini..kodenya….

#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define PORT1 0x3F8
/* INITIALISASI COM PORT */
/* COM1 0x3F8 */
/* COM2 0x2F8 */
/* COM3 0x3E8 */
/* COM4 0x2E8 */

void main(void)
{
int c;
int ch;
int x;
outportb(PORT1 + 1 , 0); /* matikan interupsi – Port1 */
/* PORT 1 – Setting Komunikasi PORT1 */
outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */
outportb(PORT1 + 0 , 0x0C); /* Set Baudrate – Divisor Latch Low Byte */
/* Default 0x03 = 38,400 BPS */
/* 0x01 = 115,200 BPS */
/* 0x02 = 56,700 BPS */
/* 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 */
clrscr();
textbackground(0);
clrscr();
textcolor(2);
clrscr();

gotoxy(33,1);
cprintf(“Tommy Agustianto”);
gotoxy(27,2);putch(0xb2);
cprintf(“Program untuk koneksi serial”);putch(0xb2);
gotoxy(26,3);
for (x=0;x<=30;x++){
textcolor(x);
putch(0xb2);
}

gotoxy(27,4);
textcolor(2);
cprintf(” tekan ESC untuk keluar”);
gotoxy(1,7);
cprintf(“\nkarakter yang di terima = \n”);
do { c = inportb(PORT1 + 5); /* Check to see if char has been */
/* received. */
if (c & 1) {ch = inportb(PORT1);
printf(“%c”,ch);} /* Print Char to Screen */
if (kbhit()){ch = getch();
printf(“%c”,ch); /* If key pressed, get Char */
outportb(PORT1, ch);} /* Send Char to Serial Port */
} while (ch !=27); /* Quit when ESC (ASC 27) is pressed */

}

//best regadsss TOMMY AGUSTIANTO 2009

Advertisements
Komunikasi Serial RS232 dengan Periperal Lain…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s