0% found this document useful (0 votes)
36 views3 pages

LCD Presentation

The code is for a PIC18F4550 microcontroller to control an LCD display. It relocates interrupt vectors, defines macros for LCD pin connections, includes LCD function definitions for initialization and character/string writing, implements a delay function, and uses the functions in main to initialize the LCD and display the string "PVG's COET PUNE".

Uploaded by

Vaibhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

LCD Presentation

The code is for a PIC18F4550 microcontroller to control an LCD display. It relocates interrupt vectors, defines macros for LCD pin connections, includes LCD function definitions for initialization and character/string writing, implements a delay function, and uses the functions in main to initialize the LCD and display the string "PVG's COET PUNE".

Uploaded by

Vaibhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

/*The following lines of code perform interrupt vector relocation to work with the

USB bootloader. These must be used with every application program to run as a USB
application.*/
extern void _startup (void);
#pragma code _RESET_INTERRUPT_VECTOR = 0x1000

void _reset (void)


{
_asm goto _startup _endasm
}

#pragma code
#pragma code _HIGH_INTERRUPT_VECTOR = 0x1008
void high_ISR (void)
{
}

#pragma code
#pragma code _LOW_INTERRUPT_VECTOR = 0x1018
void low_ISR (void)
{
}
#pragma code
//End of interrupt vector relocation

//Function to generate delay


#include<p18f4550.h>

//LCD data pins connected to PORTD and control pins connected to PORTE
#define LCD_DATA PORTD //LCD data port
#define ctrl PORTE //LCD signal port
#define en PORTEbits.RE2 //enable signal
#define rw PORTEbits.RE1 //read/write signal
#define rs PORTEbits.RE0 //register select signal
#define BUSY PORTDbits.RD7

//LCD function definitions


void LCD_Busy(void);
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
void LCD_write_string(static char*str);

void myMsDelay(unsigned int time)


{
unsigned int i, j;
for(i=0;i<710;j++);/*calibrated for a ! ms delay in MPLAB*/
}

//function to initialise the LCD


void init_LCD(void)
{
LCD_cmd(0x38); //initialization of 16x2 LCD in 8bit mode
myMsDelay(15);

LCD_cmd(0x01); //clear LCD


myMsDelay(15);

LCD_cmd(0x0C); //cursor off


myMsDelay(15);

LCD_cmd(0x80); //---8 go to first line and --0 is for 0th position


myMsDelay(15);

//---8 go to first line and --0 is for 0th position


return;
}
//Function to pass command to the LCD
void LCD_cmd(unsigned char cmd)
{
LCD_DATA = cmd;
rs = 0;
rw = 0;
en = 1;
myMsDelay(15);
en = 0;
myMsDelay(15);
return;
}

//function to write data to the LCD


void LCD_write(unsigned char data)
{
LCD_DATA = data;
rs=1;
rw=0;
en=1;
myMsDelay(15);
en=0;
myMsDelay(15);
return;
}
//function to split the string into individual characters and call the LCD_write
function
void LCD_write_string(static char*str) //store address value of the string in
pointer*str
{
int i=0;
while(str[i]!=0)
{
LCD_write(str[i]); //sending data on LCD byte by byte
myMsDelay(15);
i++;
}
return;
}
void main(void)
{
char var1[]="PVG's COET PUNE";
ADCON1 = 0x0F; //configuring the PORTE pins as digital I/O
TRISD = 0x00; // configuring PORTD as output
TRISE = 0x00; //configuring PORTE as output

init_LCD(); //initialization of LCD


myMsDelay(50); //delay of 50 mili seconds
LCD_write_string(var1);
while(1);
}
ChatGPT
The code provided appears to be designed for a PIC18F4550 microcontroller and is
aimed at controlling an LCD screen to display the string "PVG's COET PUNE".

Here's a breakdown of the code:

Interrupt Vector Relocation:

This section relocates the reset and interrupt vectors. It is crucial when working
with a USB bootloader.
LCD Control Definitions:

Macros define the connections of the LCD control and data pins to the
microcontroller's ports.
LCD Function Definitions:

LCD_Busy(): Checks if the LCD is busy.


LCD_cmd(): Sends a command to the LCD.
init_LCD(): Initializes the LCD with specific commands.
LCD_write(): Writes a character to the LCD.
LCD_write_string(): Writes a string to the LCD.
Delay Function:

myMsDelay(): Generates a delay in milliseconds. The loop count is calibrated for a


1ms delay in MPLAB.
Main Function:

Configures the ports for the LCD operation.


Initializes the LCD.
Displays the string "PVG's COET PUNE" on the LCD.
The main function initializes the ports, the LCD, and displays the given string on
the LCD screen.

Ensure that the connections between the microcontroller and the LCD are correct,
and the LCD is compatible with the control signals and data lines as defined in the
code. You might need to adjust the code based on the specifics of the LCD you are
using.

You might also like