Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/01/08 04:08
Read: times


 
#158720 - here is the lcd part of the code
Responding to: ???'s previous message
#include "lcd.h"
#include "delay.h"
#include <REGX52.H>

unsigned char code cy[]={145,145,149,142,132,132,132,132/* //Cy//*/};
unsigned char code up[]={132,142,159,142,142,142,132,128/* //up// */};
unsigned char code down[]={128,132,142,142,142,159,142,132/* //down// */};
unsigned char code block[]={159,159,159,159,159,159,159,159/* //block// */};

void lcd_reset()
{
lcd_port = 0xFF;
delayms(20);
lcd_port = 0x03+LCD_EN;
lcd_port = 0x03;
delayms(10);
lcd_port = 0x03+LCD_EN;
lcd_port = 0x03;
delayms(1);
lcd_port = 0x03+LCD_EN;
lcd_port = 0x03;
delayms(1);
lcd_port = 0x02+LCD_EN;
lcd_port = 0x02;
delayms(1);
}
void lcd_init ()
{
unsigned char i;
lcd_reset();
lcd_cmd(LCD_SETFUNCTION); // 4-bit mode - 1 line - 5x7 font.
lcd_cmd(LCD_SETVISIBLE+0x04); // Display no cursor - no blink.
lcd_cmd(LCD_SETMODE+0x02); // Automatic Increment - No Display shift.
lcd_cmd(LCD_SETCGADDR);
for(i=0;i<8;i++)
lcd_data(cy[i]);
for(i=0;i<8;i++)
lcd_data(up[i]);
for(i=0;i<8;i++)
lcd_data(down[i]);
for(i=0;i<8;i++)
lcd_data(block[i]);
lcd_cmd(LCD_SETDDADDR); // Address DDRAM with 0 offset 80h.
}

void lcd_cmd (char cmd)
{
lcd_port = ((cmd >> 4) & 0x0F)|EN;
lcd_port = ((cmd >> 4) & 0x0F);

lcd_port = (cmd & 0x0F)|EN;
lcd_port = (cmd & 0x0F);

delay(200);
delay(200);
}

void lcd_data (unsigned char dat)
{
lcd_port = (((dat >> 4) & 0x0F)|EN|RS);
lcd_port = (((dat >> 4) & 0x0F)|RS);

lcd_port = ((dat & 0x0F)|EN|RS);
lcd_port = ((dat & 0x0F)|RS);

delay(200);
delay(200);
}

void lcd_str (unsigned char *str)
{
while(*str){
lcd_data(*str++);
}
}

List of 29 messages in thread
TopicAuthorDate
lcd port switching problem            01/01/70 00:00      
   P0 does not have internal pull-ups            01/01/70 00:00      
   P1 or P2 should work similarly            01/01/70 00:00      
   i do know that about P0            01/01/70 00:00      
      But how about the control defs            01/01/70 00:00      
         yes i have moved them as well            01/01/70 00:00      
         here is the lcd part of the code            01/01/70 00:00      
            correct me if i am wrong            01/01/70 00:00      
               Tried everything?            01/01/70 00:00      
      Again, I guess you are mixing            01/01/70 00:00      
         could you please poin it out in the code            01/01/70 00:00      
   header file            01/01/70 00:00      
      the above show NOTHING, but here is a guess            01/01/70 00:00      
   hardware problem?            01/01/70 00:00      
      errors not consistent            01/01/70 00:00      
         I am somewhat puzzeled...            01/01/70 00:00      
            come conufusion with the file            01/01/70 00:00      
               My suggestion was to...            01/01/70 00:00      
                  will try that michael            01/01/70 00:00      
         Multimeter is enough            01/01/70 00:00      
            will try that out            01/01/70 00:00      
               Tests both sw and hw            01/01/70 00:00      
   lcd simulator (from keil)            01/01/70 00:00      
      i do not know your chip ...            01/01/70 00:00      
         keep in reset as in ?            01/01/70 00:00      
            if open collector supervisor and reset low            01/01/70 00:00      
   the lcd worked on P0 with pull ups            01/01/70 00:00      
      which processor?            01/01/70 00:00      
         AT89C52            01/01/70 00:00      

Back to Subject List