dsantosh
Newbie level 1
Here we go, I just jumped from the world of 8-bit controllers to 32-bit. I did some basic led blinking programs and they went well. Then I started interfacing 16x2 LCD and I got no display in the Proteus simulation. If somebody got some minutes to spare here is my code, I just intend to write alphabet 'A'
Code:
//ARM_LCD_8.c
//Author : Sierra Delta
//Date : June 24 2012
//Test Code for interfacing 16x2 LCD with ARM uC in 8-bit mode.
//Device : NXP LPC2138
//Date Modified :
#include<lpc21xx.h>
#define RS (1 << 25)
#define RW (1 << 26)
#define E (1 << 27)
//Pins 0.16 to 0.23 are used as data pins D0 to D7 respectively.
//Functions
void delay(unsigned int time);
void lcd_cmd(unsigned char item);
void lcd_data(unsigned char item);
void lcd_init(void);
//Main function
int main(void)
{
IODIR0 |= 0x00FF0000; //Data pins (0.16 to 0.23) made output pins.
IODIR0 |= RS | RW | E; //Pins 0.25 0.26 and 0.27 made output pins.
lcd_init();
lcd_cmd(0x81);
lcd_data('A');
}
void delay(unsigned int time)
{
int i,j;
for(i = 0;i < time; i++)
for(j = 0; j < 1275; j++);
}
void lcd_cmd(unsigned char item)
{
IOPIN0 = item;
IOCLR0 = RS;
IOCLR0 = RW;
IOSET0 = E;
delay(2);
IOCLR0 = E;
}
void lcd_data(unsigned char item)
{
IOPIN0 = item;
IOSET0 = RS;
IOCLR0 = RW;
IOSET0 = E;
delay(2);
IOCLR0 = E;
}
void lcd_init()
{
lcd_cmd(0x38);
delay(1);
lcd_cmd(0x0E);
delay(1);
lcd_cmd(0x01);
delay(1);
}