Activity 1. Display a message
The purpose of this activity is to display a message on the LCD 16x2.
(30 minutes)
Activity 1
Step 1. The circuit is drawn in the Proteus Design Suite.
Step 2. The program in C language is written.
Write in CCS Compiler the program in C language
#include <main.h> // the file main.h with the
// initial settings is included.
// This file must be placed in the same
// folder with the project.
// Also the 18F4550.h file must exist
// in the same folder with the project
#include <flex_lcd.h> // The h file of the lcd driver
// should be in the same folder where we will save our program.
// The #define LCD_DB4 PIN_B4 etc statements in flex_lcd.c
// should be checked and possibly modified.
// These statements determine the pins of the microcontroller
// that are connected to LCD 16x2.
#byte PORTB =0xF81 // We attribute to the memory position 0xF81 the name PORTB.
// This means that we define a 8 bit variable whose value
// will be stored to the memory position F81h.
// The memory position F81h is the PORTD data register.
void main(){
lcd_init(); // Initialization routine
lcd_putc("\f"); // Clear display
lcd_gotoxy(3,1); // The cursor moves to the third position of the first line
lcd_putc("ELECTRONICS"); // print the message on the LCD
lcd_gotoxy(4,2); // he cursor moves to the fourth position of the second line
lcd_putc("*****"); // print the message on the LCD
while(TRUE){;} //The main program does nothing. Eternal loop
Step 3. Compile the program in C in order to create the program in the microcontroller machine code (hex file).
Step 4. Load to the microcontroller the hex file (program in machine code) that was created from the CCS Compiler.
Step 5. Run the simulation and check the correct operation of the circuit.
Step 6. Suggested modifications and discussion:
!!!Module_2-4!!!
****************