HELLO A SMALL STUPID QUESTION!! I TRY TO ORDER a LCD 16*2 WITH LPC E2129 USING 4 PINES, P1.20 P1.21 P1.22 AND P1.23
PINES ARE OUTPUT,
HOW MUST I MAKE TO PUT a VALUE ON THESE PINES .
I TRYED IOSET |= VALUE
DOES NOT WORK
THANKS
HELLO A SMALL STUPID QUESTION!! I TRY TO ORDER a LCD 16*2 WITH LPC E2129 USING 4 PINES, P1.20 P1.21 P1.22 AND P1.23
PINES ARE OUTPUT,
HOW MUST I MAKE TO PUT a VALUE ON THESE PINES .
I TRYED IOSET |= VALUE
DOES NOT WORK
THANKS
Have you configured the pins as outputs?
Leon
YES COMPLETELY I YOU JOINT A PIECE OF CODE
#define LCD_D4 20
#define LCD_D5 21
#define LCD_D6 22
#define LCD_D7 23
#define LCD_DATA (1<<LCD_D7)|(1<<LCD_D6)|(1<<LCD_D5)|(1<<LCD_D4)
IODIR2 |=(1<<LCD_D7)|(1<<LCD_D6)|(1<<LCD_D5)|(1<<LCD_D4);
void out(unsigned char val)
{
IOCLR1 |= (LCD_DATA);
IOSET2 |= val;
}
THE SYNTHAXE IS RIGHT??
THANK YOU FOR HELP
SORRY
NOT IOCLR1 BUT 2
FULLY FUNCTION IS:
#include “lpc21xx_keil.h”
////////////////////////////////////////////definition des sorties////////////////////
#define LCD_D4 20 //p1.20
#define LCD_D5 21 //P1.21
#define LCD_D6 22 //P1.22
#define LCD_D7 23 //P1.23
#define LCD_RS 8
#define LCD_RW 10
#define LCD_EN 11
#define LCD_DATA (1<<LCD_D7)|(1<<LCD_D6)|(1<<LCD_D5)|(1<<LCD_D4)
#define LCD_COM (1<<LCD_RW)|(1<<LCD_EN)|(1<<LCD_RS)
#define lcd_rs_set() IOSET0 =(1<<LCD_RS)
#define lcd_rs_clr() IOCLR0 =(1<<LCD_RS)
#define lcd_en_set() IOSET0 =(1<<LCD_EN)
#define lcd_en_clr() IOCLR0 =(1<<LCD_EN)
#define lcd_rw_set() IOSET0 =(1<<LCD_RW)
#define lcd_rw_clr() IOCLR0 =(1<<LCD_RW)
/////////////////////////////////////////////////////////////////////////////////////////
void out(unsigned char val)
{
IOCLR1 |= (LCD_DATA);
IOSET1 |= val;
}
void write(unsigned char val)
{
out(val>>4);
out(val);
}
//////////////////////////////////////////fonctions de gestion//////////////////////////////////
void PRINT(unsigned char* str)
{
char Z;
int i;
lcd_rs_set(); //mode données
lcd_en_set(); //validation
for (i=0;i<16 ;i++)
{
Z=str*;*
write(Z);*
}*
}
////////////////////////////////////////////////////////////////////////////////////////////////
void lcd_control(unsigned char val){
lcd_rs_clr(); //mode commande
lcd_en_set(); //validation*
write(val);
lcd_en_clr(); //validation*
}
////////////////////////////////////////////////////////////////////////////////////////////////
lcd_init(){
lcd_rw_clr(); //mode ecriture
lcd_en_set(); //validation
lcd_control(0x28);*
lcd_control(0x01);//efface ecran*
lcd_control(0x0E); // affiche curseur*
lcd_control(0x14); //decale à droite*
lcd_en_clr() ;*
}*
/////////////////////////////////////////programme principal//////////////////////////
main(void)
{
PINSEL0=0x00000000;*
PINSEL2=0x00000000;*
IODIR0 |=(1<<LCD_RS)|(1<<LCD_RW)|(1<<LCD_EN);
IODIR1 |=(1<<LCD_D7)|(1<<LCD_D6)|(1<<LCD_D5)|(1<<LCD_D4);*
lcd_init();*
PRINT(“0123456”);*
}
DOESN’T WORK , THANK YOU FOR ANY HELP!!
I think you need to change out():
void out(unsigned char val)
{
IOCLR1 |= (LCD_DATA);
IOSET1 |= (val & 0x0F) << LCD_D4;
}
As it was, you were setting only low-numbered bits, nowhere near the actual LCD data lines.
hello
what the difference enter these two expressions?
lcd_ou t((val>>4)&0x0F);
lcd_out((val)&0x0F);
thanks
As far as I know, the most common use of IOSET and IOCLR is to use them without the OR operation (|=), because these registers already implement the OR operation implicitly.
So instead of
void out(unsigned char val)
{
IOCLR1 |= (LCD_DATA);
IOSET1 |= (val & 0x0F) << LCD_D4;
}
I think it should simply be
void out(unsigned char val)
{
IOCLR1 = (LCD_DATA);
IOSET1 = (val & 0x0F) << LCD_D4;
}
Wr.t. the other question:
lcd_out((val>>4)&0x0F) extracts the high nibble (bits 4-7) from val and sends it to lcd_out, while lcd_out((val)&0x0F) sends the low nibble (bits 0-3).
thank you
it is right about in/out ,
my lcd still off but ,i progress