Writing to HD47780 LCD After 4-bit initialization

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Writing to HD47780 LCD After 4-bit initialization

Jump to solution
1,224 Views
jonathan_abbati
Contributor III

Hello Friends!

 

I am working with the HD47780 LCD and have come across many examples and codes which state how to initialize the LCD in 4-bit mode. However, I am still having a problem writing to the LCD. I have placed my code below and I would greatly appreciate any help that anyone could offer:

 

#include <hidef.h>      /* common defines And mAcros */
#include "derivative.h"      /* derivAtive-specific definitions */


void outcmd(unsigned char commAnd);
void clear (void);
void output(unsigned char letter);

 


void main(void) {
unsigned int z;

DDRS = 0xFF;
DDRE = 0xFF;
PORTE_BIT4 = 0;
PORTE_BIT7 = 0;


for (z=0;z<=26666;z++);
outcmd(0x30);
for (z=0;z<=5465;z++);
outcmd(0x30);
for (z=0;z<=266;z++);
outcmd(0x30);
for (z=0;z<=266;z++);

PTS = 0x20;
PORTE_BIT4 = 1;
PORTE_BIT4 = 0;
for (z=0;z<=5465;z++);

outcmd(0x20);
for (z=0;z<=5465;z++);


outcmd(0x08);
for (z=0;z<=5465;z++);

clear();

 


outcmd(0x06);
for (z=0;z<=5465;z++);

outcmd(0x0E);
for (z=0;z<=5465;z++);


output ('H');

 

 

 

EnableInterrupts;


  for(;:smileywink: {
    _FEED_COP(); /* feeds the dog */
  } /* loop forever */
  /* pleAse mAke sure thAt you never leAve mAin */
}


void outcmd(unsigned char command){

  unsigned int z;
  PTS = 0xF0 & command;
  PORTE_BIT4 = 0;
  PORTE_BIT4 = 1;
    PORTE_BIT4 = 0;
  PTS = 0xF0 & (command<<4);
  PORTE_BIT4 = 1; 

  PORTE_BIT4 = 0;
   PORTE_BIT4 = 0;
  for (z=0;z<=5465;z++);
 
}

void clear(void){

  unsigned int z;
  outcmd(0x01);
  for (z=0;z<=5465;z++);
  outcmd(0x02);
  for (z=0;z<=5465;z++);
 
}

void output(unsigned char letter){

  unsigned int z;
  PORTE_BIT4 = 0;
  PORTE_BIT7 = 1;
  PTS = 0xF0 & letter;
  PORTE_BIT4 = 1;
   PORTE_BIT4 = 0;
  PTS = 0xF0 & (letter<<4);
  PORTE_BIT4 = 1;
   PORTE_BIT4 = 0;
  for (z=0;z<=266;z++);
 
}

 

Thank you so very much for your time and any input you could give would be greatly appreciated!

 

Sincerely,

Jonathan

Labels (1)
0 Kudos
1 Solution
577 Views
jonathan_abbati
Contributor III

This code actually works fine, but the problem was that the debugger has a problem running the code and displaying it. For some reason this is not possible, so if anyone else is having this problem please try closing the debugger and resetting your uC with the code already loaded in.

View solution in original post

0 Kudos
1 Reply
578 Views
jonathan_abbati
Contributor III

This code actually works fine, but the problem was that the debugger has a problem running the code and displaying it. For some reason this is not possible, so if anyone else is having this problem please try closing the debugger and resetting your uC with the code already loaded in.

0 Kudos