Write to a 2x16 LCD display with the MCU 8051 IDE on-line c

Asked

Viewed 894 times

0

I wanted to write a few words on a 2x16 LCD Display, I already have the code I’m going to expose here, but I don’t know why this gives me a mistake:

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

I’ve been in other projects, and I don’t know what it means or what I might be wrong with. 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 MCU 8051, I’d appreciate your help.

  • Here’s the new code:

  • Enter this room: http://chat.stackexchange.com/rooms/19749/discussa-mutley-e-ana-costa

  • Could you tell me which compiler you are using? If you are using avr-gcc, I think I can help you.

1 answer

1

Error means you don’t have a memory where the text will be written, so you can’t write any text.

It may be because the initialization function is not executed before the others.

EDIT

So I’m guessing from the code, RS and RW are registers indicating whether there is something to be read or written, respectively.

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

  • thanks, really the error is gone, but still no write to the LCD I’ll put here the new code to see if you can help me!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.