Thursday, May 26, 2016

L 16x2 interfacing with 8051 4-bit mode

Hi,today we are interface L(16x2) with 4 bit we are using tow good software keil and proteus same as older post l interfasing.

This article explains interfacing ofLwith8051using 4-bit mode. In this mode only four pins are used for sending data and command instructions. This mode has the advantage over the 8-bit mode as it uses less of pins. The remaining pins of the controller are available for normal use.
The Data or command is sent in nibble form (1 nibble= 4 bit) in the 4-bit mode. The higher nibble is sent first followed by the lower nibble. The function of RS, RW and EN pins remains similar to 8-bit mode.
Circuit description:Connections of L with 8051 are shown in circuit diagram. In 4-bit mode, the Data lines must be connected with D4, D5, D6 and D7 pins of L module.
Initialization:The L can be configured in 4-bit mode by sending appropriate instruction which is called “Function set” to it. The Function set is hexadecimal instruction for L MPU unit, which selects working modes of L. The “Function Set” is mentioned infollowing table:
Instruction Rs Rw D7 D6 D5 D4 D3 D2 D1 D0 Function set 0 0 0 0 1 DL N F - - Description:DL - Data Length (DL = 1 8bit, DL = 0 4bit)N - No. of Lines (N = 1 2Lines, N = 0 1Lines)F - Fonts (F = 1 5x10 dots, F = 0 5x7 dots)
According totable,the value of Function Set for 4 –bit mode will be 0010 0000(0x20) because DL=0. The value “Function Set” for the L configuration 2 line (N=1), 5X7 dots (F=0) and 4-bit (DL=0) mode will be 0010 1000(0x28).
When the power supply is given to L, it remains in 8-bit mode. Now, if 0x20 is sent, lower nibble will not be received by L because four data lines (D4-D7) are connected, so 0x02 is sent instd of 0x20.
nowsimple program for L :
#include <reg51.h>#include <l.h>
void main(){
linit();ldatas(1,"ramoliyabiren");ldelay(50);lrotade(1,'r',"");lblink(5,"Computer Zone");while(1) {}
Hi I am Ramoliya Biren.this program is open use.for using this hader file.u need to add this l.h in you are source group in keil.for using fxn
ldatas(row no,"DATA which u need to desplay"); for desplay string on l
ldata("data(only single char) which u need to desplay on l")
lblink(no of time u wont to blink data,"data which u wont to blink"); hr data desplay on row 1 only
lrotade (row no,'direction of rotaed l or r',"data which u wont to rotaed");
visit :
#ifndef _leddatas_H#define _leddatas_H
#include <reg51.h>
sfr ldata = 0xA0;sbit rs = P3^2;sbit rw = P3^3;sbit en = P3^4;
void ldelay (unsigned int itime){unsigned int i,j;for(i=0;i<itime;i++)for(j=0;j<1275;j++);}
void lcmd(unsigned char value){ldata = value;rs = 0;rw = 0;en = 1;ldelay(1);en = 0;}
void ldata (unsigned char value){ldata = value;rs = 1;rw = 0;en = 1;ldelay(1);en = 0;}
void linit(){lcmd(0x0e);lcmd(0x01);lcmd(0x80);ldelay(50);}
void lrow(unsigned char no){if (no == 1){ lcmd(0x80);}if (no ==2){ lcmd(0xC0);}}
void ldatas (unsigned char row,unsigned char *lstring){lrow(row);while (*lstring){ ldata(*lstring++);}}
void lblink(unsigned char no,unsigned char *lstring){unsigned char j;for(j=0;j<no;j++){lcmd(0x01);ldelay(50);ldatas(1,lstring);ldelay(50);}}
void lrotade(unsigned char no,unsigned char dir,unsigned char *lstring){unsigned char i;ldatas(no,lstring);if (dir == 'l'){ for (i=0;i<16;i++) { ldelay(100); lcmd(0x18); }}if (dir == 'r'){ for (i=0;i<16;i++) { ldelay(100); lcmd(0x1C); }} }

U can also download all sourcodaand alsoemulationfile fromhere.
so keep exploring 8051.....
see of emulation

No comments:

Post a Comment