[SOLVED] LCD display chararcter in reverse direction

Status
Not open for further replies.

bskumar7080

Member level 2
Joined
Feb 8, 2010
Messages
48
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,288
Location
India
Activity points
1,579
Hi all,
I interfaced 20 x 4 lCD with pic18f452. i am getting diaplay in reverse direction, wht is wrong in this code

Code:
#include <p18f452.h>
#include <xlcd.h>
#include <delays.h>

#pragma config OSC  = HS 
     #pragma config PWRT = ON 
     #pragma config WDT  = OFF, WDTPS = 1 
     #pragma config LVP  = OFF 
     #pragma config DEBUG = OFF 
     #pragma config CP0  = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF 
     #pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF 
     #pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF 

void DelayFor18TCY( void )
{
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
}
void DelayPORXLCD (void)
{
Delay1KTCYx(75); // Delay of 15ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (15ms * 16MHz) / 4
// Cycles = 60,000
return;
}
void DelayXLCD (void)
{
Delay1KTCYx(25); // Delay of 5ms
// Cycles = (TimeDelay * Fosc) / 4
// Cycles = (5ms * 16MHz) / 4
// Cycles = 20,000
return;
}


char XLCD_Disp1[] = "MICROCHIP  ";

void main( void )
{

// configure external LCD
OpenXLCD( FOUR_BIT & LINE_5X10);

BusyXLCD();
SetDDRamAddr(0x09);

BusyXLCD();
putsXLCD(XLCD_Disp1);
BusyXLCD();

while(1);


}


what is wrong in this code
 

I am using C18 compiler..

How to write command to shift Display Left, Cursor On, Cursor off.


I am getting correct output when i pass characters individually, when i pass string i am getting reverse

what is the problem,

I am able to Off cursor, but shift_left cursor, commands (WriteCmdXLCD(SHIFT_CUR_RIGHT)) are not working

Code:
include <p18f452.h>
 #include <xlcd.h>
 #include <delays.h>
 
 #pragma config OSC  = HS 
      #pragma config PWRT = ON 
      #pragma config WDT  = OFF, WDTPS = 1 
      #pragma config LVP  = OFF 
      #pragma config DEBUG = OFF 
      #pragma config CP0  = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF 
      #pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF 
      #pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF 
 
 
 void DelayFor18TCY( void )
 {
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 Nop();
 }
 void DelayPORXLCD (void)
 {
 Delay1KTCYx(75); // Delay of 15ms
 // Cycles = (TimeDelay * Fosc) / 4
 // Cycles = (15ms * 16MHz) / 4
 // Cycles = 60,000
 return;
 }
 void DelayXLCD (void)
 {
 Delay1KTCYx(25); // Delay of 5ms
 // Cycles = (TimeDelay * Fosc) / 4
 // Cycles = (5ms * 16MHz) / 4
 // Cycles = 20,000
 return;
 }
 
 
 char XLCD_Disp1[] = "M";
 char XLCD_Disp2[] = "I";
 char XLCD_Disp3[] = "C";
 char XLCD_Disp4[] = "R";
 char XLCD_Disp5[] = "O";
 char XLCD_Disp6[] = "C";
 char XLCD_Disp7[] = "H";
 char XLCD_Disp8[] = "I";
 char XLCD_Disp9[] = "P";
 
 
 void main( void )
 {
 
 // configure external LCD
 OpenXLCD( FOUR_BIT & LINES_5X7);
 
 Delay10KTCYx(20);
  /*****/
  WriteCmdXLCD(DON&CURSOR_OFF&BLINK_OFF);
  /*****/
  while(BusyXLCD()); 
  /*****/
  Delay10KTCYx(20);
 
 
 
 BusyXLCD();
 SetDDRamAddr(0x01);
 putsXLCD(XLCD_Disp1);
 BusyXLCD();
 SetDDRamAddr(0x02);
 putsXLCD(XLCD_Disp2);
 BusyXLCD();
 SetDDRamAddr(0x03);
 putsXLCD(XLCD_Disp3);
 BusyXLCD();
 SetDDRamAddr(0x04);
 putsXLCD(XLCD_Disp4);
 BusyXLCD();
 SetDDRamAddr(0x05);
 putsXLCD(XLCD_Disp5);
 BusyXLCD();
 SetDDRamAddr(0x06);
 putsXLCD(XLCD_Disp6);
 BusyXLCD();
 SetDDRamAddr(0x07);
 putsXLCD(XLCD_Disp7);
 BusyXLCD();
 SetDDRamAddr(0x08);
 putsXLCD(XLCD_Disp8);
 BusyXLCD();
 SetDDRamAddr(0x09);
 putsXLCD(XLCD_Disp9);
 BusyXLCD();
 SetDDRamAddr(0x40);
 BusyXLCD();
 while(1);
 }
 
Last edited:

It works !!!!!!!!!
I set the cursor to Return home and shifted display right
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…