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

Back to Subject List

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


 
#75379 - Reply to Ijaz: Comments + my code...
Responding to: ???'s previous message
Ijaz: thanks for your message! Yes, same hardware (8051 board, same LCD circuit also) and always on Keil uVision eval.

-Could not find complete C program for LCD after searching here, only parts of a program not ready for use more or less.

My code, with my own best attempt at a simple functional program (min. functions, simple for test purposes):
------------------------------------------------------
/*
| "LCDtest4.c"
| LCD command/data transmittal
| program for ATMEL (Temic)T80C51 
| microcontroller
======================================
| Tests operation of a connected 2x16
| LCD 44780-based display module, 8 bit 
| dat/cont. sent, 2 control bits:
| RS = control/data = 0/1 = P3.2
| E = enable = P3.4
| R/W* = P3.3
| P1 = output
| (P3 = output)
| IE = interrupts disabled
|--------------------------------------
| 8/1/04 Marty McLeod
| IDE: Keil uVision2 Eval V2.40
--------------------------------------*/

#include <reg5101.h>


unsigned int i;
unsigned int j;

//Function prototypes here
void SEND_DATA_BYTE(void);
void SEND_CONT_BYTE(void);
void BUSYF_CHK_WAIT(void);

//Begin main of program

void main(void)
{
	// Initialization of 8051:
	IE = 0;         //Interrupts disabled
	P1 = 0x00;	//Set port 1 to OUTPUT
	P3 = 0x00;	//Set port 3, all bits, to OUTPUT
//
	SP = 0x40;	//Stack pointer at 40h
	PSW = 0;	//Clear program status word PSW
//
	P3_2 = 0;       //RS,
	P3_3 = 0;       //R/W,
	P3_4 = 0;       //& E cleared first
//
/*	Initialize LCD.....	*/
	//1: Function set
	//(8 bit data, 2 lines, font=5x8 pixels)
	P1 = 0x38;
	SEND_CONT_BYTE();
	//Now clear output
	P1 = 0x00;
	//Wait for not busy
	BUSYF_CHK_WAIT();

	//2: Clear LCD
	P1 = 0x01;
	SEND_CONT_BYTE();
	//Now clear output
	P1 = 0x00;
	//Wait for not busy
	BUSYF_CHK_WAIT();
	
	//3: Disable cursor
	P1 = 0x0C;
	SEND_CONT_BYTE();
	//Now clear output
	P1 = 0x00;
	//Wait for not busy
	BUSYF_CHK_WAIT();

	//4: Entry mode set
	//Set mode to 'right'
	P1 = 0x06;
	SEND_CONT_BYTE();
	//Now clear output
	P1 = 0x00;
	//Wait for not busy
	BUSYF_CHK_WAIT();

/* Data output section */
/* Characters sent are 'U' and 'A' */

	P1 = 0x55;	//Send 'U' ASCII to LCD
	SEND_DATA_BYTE();
	//Now clear output
	P1 = 0x00;
	//Wait for not busy
	BUSYF_CHK_WAIT();

	P1 = 0x41;	//Send 'A' ASCII to LCD
	SEND_DATA_BYTE();
	//Now clear output
	P1 = 0x00;
	//Wait for not busy
	BUSYF_CHK_WAIT();


	//Enter continous loop for test purpose
	/*-------END------*/

	while(1)
	{
	}
	
}//End of MAIN

/** Define functions below **/
void SEND_CONT_BYTE(void)
 {
   P3_2 = 0;
   P3_4 = 1;
   P3_4 = 0;
  }

void SEND_DATA_BYTE(void)
 {
   P3_2 = 1;
   P3_4 = 1;
   P3_4 = 0;
   //
   //Now reset to Control format on RS bit..
   P3_2 = 0;
 }
	
void BUSYF_CHK_WAIT(void)
 {
   //Set P1 to input
   P1 = 0xFF;
   //Set R/W = 1 (read mode)
   P3_3 = 1;	   
   //Wait for not busy
   while(P1_7)
	{
	}
   //Set P1 back to output
   P1 = 0x00;
   //Clear R/W
   P3_3 = 0;	
  }
/** END OF FILE **/


List of 43 messages in thread
TopicAuthorDate
° LCD (44780) works in only ASM not C! °            01/01/70 00:00      
   RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
      Reply: Keil uVision limits            01/01/70 00:00      
         RE: Reply: Keil uVision limits            01/01/70 00:00      
            Reply to Bartosz Wucke...            01/01/70 00:00      
   RE: ° LCD (44780) works in only ASM not C! °            01/01/70 00:00      
      RE: ° LCD (44780) works in only ASM not C! °            01/01/70 00:00      
         oops-lets try tis again for the code            01/01/70 00:00      
            RE: oops-lets try tis again for the code            01/01/70 00:00      
               RE: oops-lets try tis again for the code            01/01/70 00:00      
   Reply to Ijaz: Comments + my code...            01/01/70 00:00      
      RE: Reply to Ijaz: Comments + my code...            01/01/70 00:00      
         Oleg: Thanks but no success...            01/01/70 00:00      
   RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
      RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
   RE: ° LCD (44780) works in only ASM not C! °            01/01/70 00:00      
      RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
      RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
         RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
            RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
               RE: ° LCD (44780) works in only ASM not            01/01/70 00:00      
               A scope IS a magic wand!            01/01/70 00:00      
                  Oh no it isnt!            01/01/70 00:00      
                     RE: Oh no it isnt!            01/01/70 00:00      
                        RE: Oh no it isnt!            01/01/70 00:00      
                     RE: Oh no it isnt!            01/01/70 00:00      
                        Fix it!!            01/01/70 00:00      
   Reply to Erik, Russell, Bartosz---            01/01/70 00:00      
      RE: Reply to Erik, Russell, Bartosz---            01/01/70 00:00      
      RE: Reply to Erik, Russell, Bartosz---            01/01/70 00:00      
   RE: ° LCD (44780) works in only ASM not C! °            01/01/70 00:00      
      Reply to Kai            01/01/70 00:00      
         RE: Reply to Kai            01/01/70 00:00      
            uVision Project LCD            01/01/70 00:00      
   RE: ° LCD (44780) works in only ASM not C! °            01/01/70 00:00      
      RE: memory mapped LCD            01/01/70 00:00      
      Erik, Russell, Kai...LCD Code...            01/01/70 00:00      
         RE: Erik, Russell, Kai...LCD Code...            01/01/70 00:00      
   It is time to take a look with the scope            01/01/70 00:00      
   Thanks..and final comments...            01/01/70 00:00      
      UPDATE: Traced problem to LCALL...            01/01/70 00:00      
         RE: UPDATE: Traced problem to LCALL...            01/01/70 00:00      
            Reply to Jon..            01/01/70 00:00      

Back to Subject List