Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone explain how I would go about this? Code must be written in C. I will thumbs up a detailed answer/explanation. Thanks! MCU name

Can someone explain how I would go about this? Code must be written in C. I will thumbs up a detailed answer/explanation. Thanks!

MCU name is NXP FRDM-KL25Z

image text in transcribed

Given code:

#include

#define LCD_COLUMNS 8 // Number of LCD columns in characters #define LCD_ROWS 2 // Number of LCD rows

/*-------------------- LCD interface hardware definitions --------------------*/

/* Connections from LCD to MCU port bits: DB4 through DB8 are contiguous, starting with LSB at bit position PIN_DATA_SHIFT For example: - DB4 = PTC3 - DB5 = PTC4 - DB6 = PTC5 - DB7 = PTC6 - E = PTC7 - RW = PTC8 - RS = PTC9 */

#define PIN_DATA_PORT PORTC #define PIN_DATA_PT PTC #define PIN_DATA_SHIFT ( 3 )

#define PIN_E_PORT PORTC #define PIN_E_PT PTC #define PIN_E_SHIFT ( 7 ) #define PIN_E ( 1

#define PIN_RW_PORT PORTC #define PIN_RW_PT PTC #define PIN_RW_SHIFT ( 8 ) #define PIN_RW ( 1

#define PIN_RS_PORT PORTC #define PIN_RS_PT PTC #define PIN_RS_SHIFT ( 9 ) #define PIN_RS ( 1

#define PINS_DATA (0x0F

/* Enable Clock for peripheral driving LCD pins */ #define ENABLE_LCD_PORT_CLOCKS SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTC_MASK;

#define SET_LCD_E(x) if (x) {PIN_E_PT->PSOR = PIN_E;} else {PIN_E_PT->PCOR = PIN_E;} #define SET_LCD_RW(x) if (x) {PIN_RW_PT->PSOR = PIN_RW;} else {PIN_RW_PT->PCOR = PIN_RW;} #define SET_LCD_RS(x) if (x) {PIN_RS_PT->PSOR = PIN_RS;} else {PIN_RS_PT->PCOR = PIN_RS;}

#define SET_LCD_DATA_OUT(x) PIN_DATA_PT->PDOR = (PIN_DATA_PT->PDOR & ~PINS_DATA) | ((x) PDIR & PINS_DATA) >> PIN_DATA_SHIFT) & 0x0F)

/* Setting all pins to output mode */ #define SET_LCD_ALL_DIR_OUT { PIN_DATA_PT->PDDR = PIN_DATA_PT->PDDR | PINS_DATA; \ PIN_E_PT->PDDR = PIN_E_PT->PDDR | PIN_E; \ PIN_RW_PT->PDDR = PIN_RW_PT->PDDR | PIN_RW; \ PIN_RS_PT->PDDR = PIN_RS_PT->PDDR | PIN_RS; }

/* Setting DATA pins to input mode */ #define SET_LCD_DATA_DIR_IN PIN_DATA_PT->PDDR = PIN_DATA_PT->PDDR & ~PINS_DATA;

/* Setting DATA pins to output mode */ #define SET_LCD_DATA_DIR_OUT PIN_DATA_PT->PDDR = PIN_DATA_PT->PDDR | PINS_DATA;

#define LCD_BUSY_FLAG_MASK (0x80)

/******************************************************************************/ void Init_LCD (void); void Set_Cursor (uint8_t column, uint8_t row); void Clear_LCD(void); void Print_LCD (char *string); void lcd_putchar (char c);

Task 2: Modify the LCD driver code given to you in the Lab 2 Tutorial to use PORT D bits 0-3 for the data bus (DB4-7) and PORT C bits 12, 13, and 16 for control lines E, R~W, and RS respectively. Task 2: Modify the LCD driver code given to you in the Lab 2 Tutorial to use PORT D bits 0-3 for the data bus (DB4-7) and PORT C bits 12, 13, and 16 for control lines E, R~W, and RS respectively

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

Analyse the role of corporate parenting in creating value

Answered: 1 week ago

Question

a score of 60 or higher on the test?

Answered: 1 week ago