Writing to HD47780 LCD After 4-bit initialization

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Writing to HD47780 LCD After 4-bit initialization

跳至解决方案
1,237 次查看
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

标签 (1)
0 项奖励
1 解答
590 次查看
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 项奖励
1 回复
591 次查看
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 项奖励