Qaisar Azeemi
Full Member level 5
- Joined
- Feb 11, 2011
- Messages
- 315
- Helped
- 16
- Reputation
- 32
- Reaction score
- 15
- Trophy points
- 1,298
- Location
- Peshawar, Pakistan, Pakistan
- Activity points
- 3,829
#define RS PORTD.F4 //RD4
#define EN PORTD.F5 //RD5
#define Lcdport PORTC //lcd data pins
void lcd_ini();
void dis_cmd(unsigned char);
void dis_data(unsigned char);
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void main()
{
TRISD.f4 = 0;
TRISD.f5 = 0;
TRISB.f2 = 0x00;
TRISB.f3 = 0x00;
// TRISC.f0 =0xff;
// TRISC.f1 =0xff;
TRISC=0x00; //portC output
unsigned char data0[]="Shenztech PvtLtd";
unsigned int i=0;
lcd_ini();
while(1)
{
for (i=0; i!='\0'; i++)
{
dis_data(data0[i]);
Delay_ms(200);
}
}
}
//..............................;;;;;;;.........................................
void lcd_ini()
{
dis_cmd(0x02); // 4 bit mode select
dis_cmd(0x28); //2 line; 5x7 display; 4bit mode
dis_cmd(0x0c);
dis_cmd(0x06);
dis_cmd(0x80); //start from line 1 character 0
}
//..............................;;;;;;;........................................
void dis_cmd(unsigned char cmd_value)
{
unsigned char cmd_value1;
cmd_value1=(cmd_value & 0xf0); // mask the lower nibble
lcdcmd(cmd_value1); //send to lcd
cmd_value1=((cmd_value1<<4) & 0xf0);
lcdcmd(cmd_value1);
}
//................................;;;;;.........................................
void lcdcmd(unsigned char cmdout)
{
Lcdport=cmdout;
RS=0;
EN=1;
Delay_ms(10);
EN=0;
}
//.............................;;;;;;.........................................
void lcddata(unsigned char dataout)
{
Lcdport=dataout;
RS=1;
EN=1;
Delay_ms(10);
EN=0;
}
void main()
{
unsigned char data0[]="Shenztech PvtLtd";
unsigned int i=0;
TRISD.f4 = 0;
TRISD.f5 = 0;
TRISB.f2 = 0x00;
TRISB.f3 = 0x00;
// TRISC.f0 =0xff;
// TRISC.f1 =0xff;
TRISC=0x00; //portC output
lcd_ini();
while(1)
void dis_data(unsigned char);
dis_data(data0[i]);
void dis_data(unsigned char) // function header
{
.... // function code
}
// Write a nibble to the LCD
// may have to adjust delays to suit the processor and clock
void lcdNibble(int n)
{
int lcd=LCDdata;
mSecDelay(1);
LCDdata = (lcd&0xfff0) | ((n & 0x0f)); // send out lower Nibble
mSecDelay(1);
LCDstatus.E=1; // take clock E high
mSecDelay(1);
LCDstatus.E=0;
mSecDelay(1);
}
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
void main(){
TRISB = 0x00; // Configure PORTB pins as digital
PORTB = 0x00;
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1) { // Endless loop
Lcd_Out(1,1,"Shenztech PvtLtd"); // Write text in first row
}
}
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
void main(){
TRISB = 0x00; // Configure PORTB pins as digital
PORTB = 0x00;
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1) { // Endless loop
Lcd_Out(1,1,"Shenztech PvtLtd"); // Write text in first row
//Lcd_Cmd(_LCD_SHIFT_LEFT);
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Delay_ms(250);
}
}
hey Qaisar Azeemi you can look under the tools menu of mikro C pro for lcd custom character edit. its very versatile tool. the rest of it is in documentation.
an advice: do not use these kind of heavily library dependent software, it will make us very lazy and we will be ignorant about all the internal workings of the controller.
TRISA = 0xFF;
TRISE = 0b111;
To configure PORTA and PORTE as input ports
Code:TRISA = 0xFF; TRISE = 0b111;
hey qaisar its all in the documentation section of the mikro c . run the pgm and click on the help button. you can search for timers and interrupts there. Documentation is hmm.. brief. you can learn from there.thank you very much... i have a few questions regarding pic programming.
1) how to program timers and interrupts using mikroC.
you can do that by either overwriting the text or clearing the lcd by using the command2) how to clear the LCD display data RAM? because i want to shift a text on lcd screen under normal conditions, but when the controller detect some signal at its any input it should change the data in display data RAM permanently with other given data.
Lcd_Cmd(_LCD_CLEAR);
you can clear the lcd for that.3)how to change command to lcd. i.e; deactivate one command and activate other. i used
Lcd_Cmd(_LCD_SHIFT_RIGHT); to display a data on screen but when i change the data and want it to b still on lcd rather moving but the right shift command reactivated again and starting shifting it.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?