Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

LCD 1X40

Raccolta di codici sorgenti

Moderatore: Foto UtentePaolino

0
voti

[1] LCD 1X40

Messaggioda Foto Utentecencia » 13 apr 2014, 21:33

Salve a tutti,
sto programmando un LCD 1x40 , ma le scritte si fermano tutte alla prima metà del LCD

i l codice inputato:

Codice: Seleziona tutto
#if LCD_CURSOR_VISIBLE==1
   #if LCD_CURSOR_BLINK==1
   #define LCD_CONTROL 0b00001111
   #else
   #define LCD_CONTROL 0b00001110
   #endif
#else
   #define LCD_CONTROL 0b00001100
#endif

#define LCD_CLR  0x01 // Clears Display
#define LCD_HOME 0x02 // Cursor to Home position

#define LCD_line1 0x80 // Cursor to Line 1 position 1
#define LCD_line2 0xC0 // Cursor to Line 2 position 1

#if (LCD_COLS==20)
   #define LCD_line3 0x94 // Cursror to Line 3 position 1 (20 char LCD)
   #define LCD_line4 0xD4 // Cursor to Line 4 position 1 (20 char LCD)
#else
   #define LCD_line3 0x90 // Cursor to Line 3 position 1 (16 char LCD)
   #define LCD_line4 0xD0 // Cursor to Line 4 position 1 (16 char LCD)
#endif

void LCD_GOTO (char line,char pos)
   {
   switch(line)
      {
      case 1: LCD_CMD((LCD_line1-1)+pos);
      break;
      
      case 2: LCD_CMD((LCD_line2-1)+pos);
      break;
      
      case 3: LCD_CMD((LCD_line3-1)+pos);
      break;
      
      case 4: LCD_CMD((LCD_line4-1)+pos);
        break;
      }
   }

void LCD_PUTS (const char * s)
   {
   LCD_RS = 1; // write characters
   while(*s)
      LCD_WRITE(*s++);
   }

void LCD_INIT (void)
   {
   
   LCD_RS = 0; // write control bytes
   DelayMs(50); // power on delay

   LCD_D4=1;
   LCD_D5=1;
   LCD_D6=0;
   LCD_D7=0;

   LCD_STROBE();
   DelayMs(6);

   LCD_STROBE();
   DelayUs(150);

   LCD_STROBE();
   DelayMs(6);

   LCD_D4=0; // set 4 bit mode
   LCD_STROBE();
   
   DelayUs(100);
   
   #if (LCD_ROWS==1)
      LCD_WRITE(0b00100000);   // 4 bit mode, 1 line, 5x8 font
   #else
      LCD_WRITE(0b00101000);   // 4 bit mode, 2 or more lines, 5x8 font
   #endif
   
   LCD_WRITE(0b00001000); // display off
   LCD_WRITE(0b00000000); // clear display
   LCD_WRITE(LCD_CONTROL); // display on, set the cursor behavior as specified
   LCD_WRITE(0b00000110); // entry mode, display not shifted, cursor increments
   }

void main()
        {
           
        int i=0;
      settings();
        LCD_INIT(); // inizializzo l'LCD
      LCD_CLEAR(); // ripulisco il display
      // Preparo le scritte sul display
      LCD_GOTO(1,1);
      LCD_PUTS("Controllo Temp. Caldaia BELLIGOLI");
        DelayMs(5000);
}





In questo punto (1,20) mi si fermano tutte le stringhe.

se qualcuno ha un po' di pazienza da controllare dove sbaglio....!!!! vi sarei molto grato....!!!

#-o
Avatar utente
Foto Utentecencia
8 1 5
New entry
New entry
 
Messaggi: 98
Iscritto il: 1 giu 2012, 22:10

Torna a Firmware e programmazione

Chi c’è in linea

Visitano il forum: Nessuno e 9 ospiti