Pemrograman Atmel AT89S52 Menggunakan USB ISP dan Development Board 8051 dan LCD Karakter 16×2
Tutorial berikut ini memberikan informasi mengenai penggunaan dari development board 8051 bersamaan dengan USB ISP. IC Atmel yang kita program adalah tipe AT89S52. Untuk memprogram IC Atmel tipe AT89S52, kita memerlukan software untuk coding, dan software untuk flash ke IC. Tutorial software diperoleh dari tutorial sebelumnya disini.
Adapun peralatan yang kita gunakan untuk melakukan pemrograman IC Atmel adalah sebagai berikut :
LCD 16×2 yang digunakan adalah LCD standard karakter, pada development board sudah tersedia port untuk LCD yang terhubung langsung dengan pin pada PORC di 8051, perhatikan gambar berikut ini :
Setelah semua bagian kita hubungkan :
- IC Atmel AT89S52 ditempatkan pada soket flash development board
- LCD 16×2 sudah ditempatkan pada soket pin header LCD di development board
- Ujung yang satu dari IDC kabel dari USB ISP Programming sudah terhubung di development board
Rangkaian menjadi sebagai berikut :
Kemudian sebelum menghubungkan ke komputer, kita perlu menggunakan software pemrograman uVision (Keil) dan progISP (dapat didownload disini). Adapun script yang digunakan dalam bahasa C dapat dicopy berikut ini :
//--------------------------
//LCD Interface with AT89S52
//--------------------------
#include<reg52.h>
//----------------------------------------------
sbit RS = P1^2;
sbit RW = P1^1;
sbit EN = P1^0;
//======================================================
//delay in milliseconds
void delay(unsigned int time)
{
unsigned int i, j;
for(i=0; i<time; i++)
for(j=0; j<1275; j++);
}
//======================================================
//send command to LCD
void LCD_command(unsigned char command)
{
P2 = command;
RS = 0; RW = 0;
EN = 1; delay(1); EN = 0;
}
//======================================================
//send data to LCD
void LCD_data(unsigned char disp_data)
{
P2 = disp_data;
RS = 1; RW = 0;
EN = 1; delay(1); EN = 0;
}
//======================================================
void main()
{
unsigned char message1[15] = "Atmel AT89S52";
unsigned char message2[16] = "Counter: ";
unsigned int i, j;
//------------------------------------------------
LCD_command(0x38); //2 lines & 5X7 matrix of LCD
delay(10);
LCD_command(0x0F); //display ON, cursor ON
delay(10);
//------------------------------------------------
while(1)
{
LCD_command(0x01); //clear screen
delay(10);
LCD_command(0x81); //cursor line 1 pos 1
delay(10);
//-----------------------------------------------
i=0;
while(message1[i] != '//--------------------------
//LCD Interface with AT89S52
//--------------------------
#include<reg52.h>
//----------------------------------------------
sbit RS = P1^2;
sbit RW = P1^1;
sbit EN = P1^0;
//======================================================
//delay in milliseconds
void delay(unsigned int time)
{
unsigned int i, j;
for(i=0; i<time; i++)
for(j=0; j<1275; j++);
}
//======================================================
//send command to LCD
void LCD_command(unsigned char command)
{
P2 = command;
RS = 0; RW = 0;
EN = 1; delay(1); EN = 0;
}
//======================================================
//send data to LCD
void LCD_data(unsigned char disp_data)
{
P2 = disp_data;
RS = 1; RW = 0;
EN = 1; delay(1); EN = 0;
}
//======================================================
void main()
{
unsigned char message1[15] = "Atmel AT89S52";
unsigned char message2[16] = "Counter: ";
unsigned int i, j;
//------------------------------------------------
LCD_command(0x38); //2 lines & 5X7 matrix of LCD
delay(10);
LCD_command(0x0F); //display ON, cursor ON
delay(10);
//------------------------------------------------
while(1)
{
LCD_command(0x01); //clear screen
delay(10);
LCD_command(0x81); //cursor line 1 pos 1
delay(10);
//-----------------------------------------------
i=0;
while(message1[i] != '\0')
{
LCD_data(message1[i]);
i++;
delay(30);
}
//-----------------------------------------------
LCD_command(0xC3); //jump to 2nd line pos 3
//-----------------------------------------------
i=0;
while(message2[i] != '\0')
{
LCD_data(message2[i]);
i++;
}
delay(100);
//-----------------------------------------------
LCD_command(0x0C); //display ON, cursor OFF
for(j=0x30; j<=0x39; j++)
{
LCD_data(j);
LCD_command(0xC11); //jump to 2nd line pos 11
delay(100);
}
//------------------------------------------------
delay(150);
}
}
')
{
LCD_data(message1[i]);
i++;
delay(30);
}
//-----------------------------------------------
LCD_command(0xC3); //jump to 2nd line pos 3
//-----------------------------------------------
i=0;
while(message2[i] != '//--------------------------
//LCD Interface with AT89S52
//--------------------------
#include<reg52.h>
//----------------------------------------------
sbit RS = P1^2;
sbit RW = P1^1;
sbit EN = P1^0;
//======================================================
//delay in milliseconds
void delay(unsigned int time)
{
unsigned int i, j;
for(i=0; i<time; i++)
for(j=0; j<1275; j++);
}
//======================================================
//send command to LCD
void LCD_command(unsigned char command)
{
P2 = command;
RS = 0; RW = 0;
EN = 1; delay(1); EN = 0;
}
//======================================================
//send data to LCD
void LCD_data(unsigned char disp_data)
{
P2 = disp_data;
RS = 1; RW = 0;
EN = 1; delay(1); EN = 0;
}
//======================================================
void main()
{
unsigned char message1[15] = "Atmel AT89S52";
unsigned char message2[16] = "Counter: ";
unsigned int i, j;
//------------------------------------------------
LCD_command(0x38); //2 lines & 5X7 matrix of LCD
delay(10);
LCD_command(0x0F); //display ON, cursor ON
delay(10);
//------------------------------------------------
while(1)
{
LCD_command(0x01); //clear screen
delay(10);
LCD_command(0x81); //cursor line 1 pos 1
delay(10);
//-----------------------------------------------
i=0;
while(message1[i] != '\0')
{
LCD_data(message1[i]);
i++;
delay(30);
}
//-----------------------------------------------
LCD_command(0xC3); //jump to 2nd line pos 3
//-----------------------------------------------
i=0;
while(message2[i] != '\0')
{
LCD_data(message2[i]);
i++;
}
delay(100);
//-----------------------------------------------
LCD_command(0x0C); //display ON, cursor OFF
for(j=0x30; j<=0x39; j++)
{
LCD_data(j);
LCD_command(0xC11); //jump to 2nd line pos 11
delay(100);
}
//------------------------------------------------
delay(150);
}
}
')
{
LCD_data(message2[i]);
i++;
}
delay(100);
//-----------------------------------------------
LCD_command(0x0C); //display ON, cursor OFF
for(j=0x30; j<=0x39; j++)
{
LCD_data(j);
LCD_command(0xC11); //jump to 2nd line pos 11
delay(100);
}
//------------------------------------------------
delay(150);
}
}
Setelah dicompile (Build), maka akan didapatkan file hexadesimal (.HEX) yang akan kita flash ke IC menggunakan software ProgISP. Adapun file .hex dapat didownload pada link berikut ini.
Berikut ini video untuk detail dari langkah-langkah yang sudah dijelaskan diatas :
Post Comment
You must be logged in to post a comment.