Question: /* * File: LCDLab.c * Author: nepa6953 * Created on Feb 24, 2016 * Lab 4 - ENGR331 * The goal of this lab is

/* * File: LCDLab.c * Author: nepa6953 * Created on Feb 24, 2016 * Lab 4 - ENGR331 * The goal of this lab is help you figure out * (on your own) how to interface to a peripheral * that you have never used before based on the * documentation you find (either datasheet or other * available sources/examples online). * ENJOY!!! (and I really mean it!) */ #include "stm32f4xx.h" #include  /******************************* * Global variables ******************************* */ /******************************* * FUNCTION PROTOTYPES ******************************* */ // LIST Functions void tim6_delay(void) void LCD_port_init(void); void LCD_init(void); void LCD_write(unsigned char data); void place_lcd_cursor(unsigned char lineno); // END Functions /******************************* * START OF ACTUAL CODE ******************************* */ /******************************* * main() * Inputs: NONE * Outputs: NONE * Main function. Goals: * Initialize LCD Port * Initialize LCD * Place Cursor on Line 1 * Write character string to Line 1 * Place Cursor on Line 2 * Write character string to Line 2 ******************************* */ int main(void) { // enter your code here. return 0; } /******************************* * tim6_delay(void) * Inputs: NONE * Outputs: NONE * Based on PSC=0 and ARR=21000; * we get delay of approximately 1.33ms ******************************* */ void tim6_delay(void){ // enable APB1 bus clock RCC->APB1ENR|=RCC_APB1ENR_TIM6EN; //TIM6 prescaler set at default to 0 for now TIM6->PSC=0; // prescalar TIM6->ARR = 21000; //auto reload register TIM6->CNT=0; //clear counter register TIM6->CR1|=TIM_CR1_CEN; //WHEN COUNTER IS DONE THE TIM6_SR REG UIF FLAG IS SET while(TIM6->SR==0); TIM6->SR=0; //CLEAR uIF FLAG } /******************************* * LCD_port_init() * Inputs: NONE * Outputs: NONE * Port Initialization * Refer to the QQIKFLASH schematic * see what ports are used to connect * the PIC18F452 with the HD44780 LCD driver * set appropriate pins as digital input/outputs ******************************* */ void LCD_port_init(){ } /******************************* * LCD_init() * Inputs: NONE * Outputs: NONE * LCD Initialization * Read the manual carefully * We are doing initialization by instruction * Don't rush it. ******************************* */ void LCD_init(){ } /******************************* * place_lcd_cursor() * Inputs: unsigned character * Outputs: NONE * sets Cursor position to * Line 1, character 1 (hex address 0x80) * or Line 2, character 1 (hex addres 0xC0) * ******************************* */ void place_lcd_cursor(unsigned char lineno){ } /******************************* * LCD_write() * Inputs: unsigned character data (8-bit) * Outputs: NONE * writes the character to LCD. * ******************************* */ void LCD_write(unsigned char data) { } 

Most likely when using embedded systems, you will be talking to peripherals that you might never have used before. How do you connect the peripheral, how do you communicate with it? These questions can be answered by carefully reading the datasheet for the peripherals. Please pay attention to timing information, data transfer protocols etc. The goal of this lab is help you figure out (on your own) how to interface to a peripheral that you have never used before based on the documentation you find (either datasheet or other available sources/examples online). ENJOY!!! (and I really mean it!)

That is the LCDLab.c file above. Move it to your Project Folder and add it to your project. It provides a rough skeleton of the LCD code.

Your goal today is to figure out how to write messages to the LCD screen:

READ the HD44780LCD Datasheet (PDF is also available on Blackboard).

Write a message on the two lines (remember that although it is a 1 line LCD, you treat the 9th

character as being line 2 of the LCD). You will need to complete the following functions:

voidLCD_port_init();//InitializethePORTconnectionsforusewithLCD

void LCD_init(); // Initialize the LCD for 4-bit mode

voidplace_lcd_cursor(charlineno);//PlaceLCDcursorateitherline1

or Line 2. Line 1 starts at address 0x80; Line 2 starts at address 0xC0.

You will also need to think about one or more FUNCTIONS THAT ALLOW you to

What to hand in?

send actual message to be printed on the screen. For example you need to print these four types of messages: Individual characters: H String: HELLO ENGR

Numbers in decimal : 331 Numbers in Hexadecimal: 0x331

Hand in WELL COMMENTED C code.

Write a summary (no more than 2 pages) on how you accomplished part 2 (d). The summary

should explain clearly the approach of the functions. We will grade you based on whether we are able to replicate the methods purely based on your description.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!