i have written the following code for LCD interfacing in 4 bit mode to ez430-rf2500
#include<msp430x22x4.h>
#define lcd_data P2OUT;
#define set_rs P4OUT|=BIT4;
#define clear_rs P4OUT&=~BIT4;
#define set_en P4OUT|=BIT5;
#define clear_en P4OUT&=~BIT5;
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void delay(unsigned int);
void lcdcmdi(unsigned char);
unsigned char h_byte,l_byte;
unsigned int mesg;
void main()
{
P2DIR|= BIT0+BIT1+BIT2+BIT3;
P4DIR|=BIT4+BIT5;
unsigned char i=0;
unsigned char command[] = {0x28,0x0E,0x01,0x06,0x80,0};
unsigned int temp= 32;
unsigned char p,q;
delay(20);
lcdcmdi(0x30);
delay(10);
lcdcmdi(0x30);
delay(1);
lcdcmdi(0x30);
delay(1);
lcdcmdi(0x20);
delay(1);
while(1)
{
mesg=temp;
p=(mesg/10)+48;
q=(mesg%10)+48;
for (i=0;command[i]!=0;i++)
{
lcdcmd(command[i]);
}
lcddata(p);
lcddata(q);
}
}
void lcdcmdi(unsigned char value)
{
value >>=4;
lcd_data=value;
clear_rs;
set_en;
delay(10);
clear_en;
return;
}
void delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void lcdcmd(unsigned char value)
{
l_byte = value & 0x0f;
h_byte = (value>>4) & 0x0f;
lcd_data=h_byte;
clear_rs;
set_en ;
delay(10);
clear_en = 0;
lcd_data=l_byte;
set_en;
delay(10);
clear_en=0;
return;
}
void lcddata(unsigned char value)
{
l_byte = value & 0x0f;
h_byte = (value>>4) & 0x0f;
lcd_data=h_byte;
set_rs ;
set_en ;
delay(10);
clear_en;
lcd_data=l_byte;
set_en;
delay(10);
clear_en;
return;
}
************************************************************************************************************************************************
but i found that p2.6 ,p2.7 are used for communication with antenna.so, i can't disturb them.
is there any way i can only 4 bits in lcd_data.because p2out refers to all 8 bits.
when i send a nibble the upperbits of p2out will be 0 .this disturbs antenna apllication.
how can i configure only 4 bits to be in output mode in lcd_data?
plz help!