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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/02/08 14:35
Modified:
  02/02/08 14:38

Read: times


 
#150222 - It worked!
Responding to: ???'s previous message
Yey :)
I just took a resistor without thinking it would work and just warping its legs around the pins. tieing d0-d3 to ground, didn't work. tried to VCC - WORKS :D now ill just solder it :)

Maybe this model does not have pullups :O (Edit, while not connected, voltage on data pins is 3.5V - could be not enough)
Anyway it works :D

Heres the code that works:




#include <at89x52.h>
#include <stdio.h>
#include <string.h>

#define LCD_RS              P3_6
#define LCD_E               P3_7
#define LCD_BUS_PORT        P0

//Delay in ms (at 12MHZ Crystal)
void delay_ms(unsigned  int ms) {
	TMOD = (TMOD & 0xF0) | 0x01;  //Set Timer0 to mode 1 (16 bit counter)
	TR0 = 1;                      //Start the timer]

	while (ms > (unsigned char) 64) {
		TH0 = 0x06; TL0 = 0x00;   //Reset the timer count to -64000 (Will take 64ms to complete)
		TF0 = 0;                  //Reset overflow flag
		while (TF0 != 1);         //Wait until Timer1 overflows

		ms -= (unsigned char) 64;
	}
	while (ms != (unsigned char) 0) {
		TH0 = 0xFC; TL0 = 0x18;   //Reset the timer count to -1000 (Will take 1ms to complete)
		TF0 = 0;                  //Reset overflow flag
		while (TF0 != 1);         //Wait until Timer1 overflows
		
		ms--;
	}

	TR0 = 0;                      //Stop the timer
}



void E_clk() {
	delay_ms(1);
	LCD_E =0; 
	delay_ms(1);
	LCD_E=1;
	delay_ms(1);
	LCD_E =0; 
}

void main() {
	unsigned char buffer[] = "Hello world";
	unsigned char *p;
	unsigned int i;
	
	//Toggle led 
	for (i = 0; i < 2; i++) {
		P2_7 = 1;
		delay_ms(50);
		P2_7 = 0;
		delay_ms(50);
	}

	//Power on
	//Wait more than 15 msecs after power is applied.
	delay_ms(40); 

	LCD_RS = 0; //instructions

	LCD_BUS_PORT = 0x30;
	E_clk();
	delay_ms(10);

	LCD_BUS_PORT = 0x30;
	E_clk();

	LCD_BUS_PORT = 0x30;
	E_clk();

	LCD_BUS_PORT = 0x20;
	E_clk();

	//0x28 (4Bit mode,2Lines,Small font)
	LCD_BUS_PORT = 0x20;
	E_clk();
	LCD_BUS_PORT = 0x80;
	E_clk();

	//0x08 (Display off)
	LCD_BUS_PORT = 0x00;
	E_clk();
	LCD_BUS_PORT = 0x80;
	E_clk();

	//0x01 (Clear the display)
	LCD_BUS_PORT = 0x00;
	E_clk();
	LCD_BUS_PORT = 0x10;
	E_clk();
	delay_ms(10);

	//0x06 (Entry mode - no shifting, auto increase)
	LCD_BUS_PORT = 0x00;
	E_clk();
	LCD_BUS_PORT = 0x60;
	E_clk();

	//0x0E (Display on)
	LCD_BUS_PORT = 0x00;
	E_clk();
	LCD_BUS_PORT = 0xE0;
	E_clk();

	LCD_RS = 1;


	
p = buffer;
	while (*p) {
		LCD_BUS_PORT = *p;
		E_clk();
		LCD_BUS_PORT = *p << 4;
		E_clk();

		p++;
	}
	


	while(1);
}


List of 44 messages in thread
TopicAuthorDate
LCD in 4Bit mode trouble            01/01/70 00:00      
   For a start            01/01/70 00:00      
   How to post source code            01/01/70 00:00      
   HD44780 in 4 bit mode timings            01/01/70 00:00      
      Thanks, but still doesnt work            01/01/70 00:00      
         Tied lines            01/01/70 00:00      
            RW line tied to GND            01/01/70 00:00      
               R/W is tied to ground by hardware            01/01/70 00:00      
               have a look at this in code library            01/01/70 00:00      
            It worked!            01/01/70 00:00      
               It worked!            01/01/70 00:00      
                  d0-d3            01/01/70 00:00      
                     d0-d3 I still insist they should be left open !            01/01/70 00:00      
                        Proof            01/01/70 00:00      
                           They already have internal pullups            01/01/70 00:00      
                              Where ?            01/01/70 00:00      
                                 Please find the " Pull-up MOS " in the datasheet            01/01/70 00:00      
                                    Thanks            01/01/70 00:00      
                        I never insisted ont tieing them            01/01/70 00:00      
   can\'t help it            01/01/70 00:00      
      Noritake            01/01/70 00:00      
         Noritake            01/01/70 00:00      
            'life' for as long as it lasts            01/01/70 00:00      
               Please provide the datasheet part info            01/01/70 00:00      
                  I do not have it            01/01/70 00:00      
   I never insisted ont tieing them            01/01/70 00:00      
      Powertip - pc1602f            01/01/70 00:00      
   2 more things            01/01/70 00:00      
   I am getting 50\'000Hrs , with 80Cd/m2 , they            01/01/70 00:00      
   I work in 4 bit mode            01/01/70 00:00      
      All that code reduces to:            01/01/70 00:00      
         Thanks by the code size reduction            01/01/70 00:00      
            Tools            01/01/70 00:00      
               sure, but why            01/01/70 00:00      
                  time for a new thread...            01/01/70 00:00      
            Free IDE            01/01/70 00:00      
               it does not make sense            01/01/70 00:00      
                  Ops,,, Topic changes!            01/01/70 00:00      
                     one thing at a time            01/01/70 00:00      
                        Why bin file and not hex directly            01/01/70 00:00      
                  re: it does not make sense            01/01/70 00:00      
                     it does not matter 'how long'            01/01/70 00:00      
                        Not recommending anything            01/01/70 00:00      
         The swap command should not exist !!?            01/01/70 00:00      

Back to Subject List