Write on a 2x16 LCD display with the 8051 IDE MCU in language c

0

I wanted to write a few words on a LCD Display 2x16, I already have the code that I will expose here, but I do not know why this gives me an error:

  

HD44780 ERROR: Neither 'Set DDRAM ADDRESS' nor '' Set CGRAM ADDRESS '   instruction was issued prior to the write instruction.

It has already appeared in other projects and I do not know what it means or what I can do wrong. Here is my code:

#include "sdcc_reg420.h"
#define LCD_PORT P1
#define En P3_5
#define RS P3_1
#define RW P3_0

void LCD_comando(unsigned char comando);
void LCD_init (void);
void LCD_date(char letra);
//void inicio ();

void LCD_init (void)            //inicialização do LCD
{
    LCD_comando(0b00111000);    //duas linhas e caracteres 5x7
    LCD_comando(0b00001111);    //cursor ON,DisplayON, Piscar ON
    LCD_comando(0b00000001);    //Limpar o LCD
    LCD_comando(0b00000110);    //modo de entrada de dados: em incremento e Shift total off
    LCD_comando(0b10000000);    //modo de entrada de dados: endreço inicial da memoria DDRAM
}

void LCD_comando(unsigned char comando)
{
  LCD_PORT=comando;
  RS=0;
  RW=0;
  En=0;
  En=1;
}


void LCD_date(char letra)
{
  LCD_PORT=letra;
  RS=1;
  RW=0;
  //En=0;
  En=1;
}


void main (void)
{
  LCD_date(' ');
  LCD_date(' ');
  LCD_date('B');
  LCD_date('O');
  LCD_date('M');
  LCD_date('B');
  LCD_date('A');
  LCD_date('S');
  LCD_date('T');
  LCD_date('I');
  LCD_date('C');
  LCD_date('O');
  LCD_date(' ');
  LCD_date(' ');
  LCD_date(' ');
  LCD_date(0);
  LCD_comando(0b11000000);
  LCD_date(' ');
  LCD_date(' ');
  LCD_date('A');
  LCD_date('N');
  LCD_date('A');
  LCD_date(' ');
  LCD_date('C');
  LCD_date(' ');
  LCD_date('M');
  LCD_date('A');
  LCD_date(' ');
  LCD_date(' ');
}

The IDE I'm using is the 8051 MCU, I appreciate your help.

    
asked by anonymous 26.12.2014 / 15:45

1 answer

1

The error means that you do not have a memory where the text will be written, so you can not write any text.

It may be because the startup function does not run before the others.

EDIT

From what I infer from the code, RS and RW are registers that indicate whether something has to be read or written, respectively.

In the case of LCD_comando , both are receiving 0, indicating that nothing has been read or written, but in LCD_date only RS , which indicates something to read, which is receiving 1 , so anyway, the LCD is just reading characters.

    
26.12.2014 / 16:08