Question: #include /* common defines and macros */ #include derivative.h /* derivative-specific definitions */ void flash(void); //declaring the flash function void blink(unsigned char value); //declaring the
#include
#include "derivative.h" /* derivative-specific definitions */
void flash(void); //declaring the flash function
void blink(unsigned char value); //declaring the blink function
void SerTx0(unsigned char); //declaring the SerTx0 function
void SetUpLCD(void); //declaring the SetupLCD function
void clearscrean(void); //declaring the clearcrean function
void DisplayChar(unsigned char); //declaring the Didsplsy char function
void WriteLCD(unsigned char , unsigned char); //declaring the WriteLCD function
void SerTx1(unsigned char);
void MSDelay(unsigned char); //declaring the Delay function
void main(void) {
unsigned char myString[] = "Hello"; //declaring my string
unsigned char i; //declaring i
unsigned char n; //declaring c
unsigned char mode; //declaring mode
//LCD sut up
DDRB = 0xFF;
DDRJ = 0xFF;
PTJ = 0x00;
DDRH = 0x00; //Enable port H
SCI1BDH = 0x00; // value depends on desired baud rate (usually 0)
SCI1BDL = 0x1A; // value depends on desired baud rate
SCI1CR1 = 0x00; // we will always set this to 0x00
SCI1CR2 = 0x0C; // value depends on transmit/receive enabling
SetUpLCD(); //Calling the set up LCD
clearscrean(); //clearing the screan
for(i=0;i { DisplayChar(myString[i]); // Displaying char in LCD } for(;;) { if((PTH & 0x80)!=0) //if statement { blink((PTH & 0x0F)); //calling the blink function MSDelay(1000); // calling the delay } else // else statement { flash(); //calling the flash function } } } void MSDelay(unsigned char t) //The MSDelay function definition: { unsigned int i; unsigned int j; for(i=0;i for(j=0;j<2020;j++); } void SetUpLCD(void) { DDRK = 0xFF; // set Port K to output WriteLCD(0x33,0); // reset sequence provided by data sheet MSDelay(1); WriteLCD(0x32,0); // reset sequence provided by data sheet MSDelay(1); WriteLCD(0x28,0); // 2 lines and 5x7 matrix (4-bit) MSDelay(1); WriteLCD(0x06,0); // increment cursor after each character MSDelay(1); WriteLCD(0x0E,0); // Display on, cursor blinking } void clearscrean(void) //The clearscrean function definition: { MSDelay(1); WriteLCD(0x01,0); // Clear display screen MSDelay(1); WriteLCD(0x80,0); // Force cursor to beginning of 1st line MSDelay(1); } void DisplayChar (unsigned char c) //The Displaychar function definition: { WriteLCD(c,1); MSDelay(1); } void WriteLCD(unsigned char command, unsigned char mode) //The writeLCD function definition: { unsigned char x; if (mode == 0) { PORTK = PORTK & ~0x01; // set PK0 = 0 for command mode MSDelay(1); } else { PORTK = PORTK | 0x01; // set PK0 = 1 for data mode MSDelay(1); } x = (command & 0xF0) >> 2; // clear lower nibble of command // shift upper nibble to PK5-PK2 PORTK = PORTK & ~0x3C; // clear PK5-PK2 PORTK = PORTK | x; // set PK5-PK2 to upper nibble of command MSDelay(1); // send high-low pulse to PK1 to enable latching of command PORTK = PORTK | 0x02; // high MSDelay(5); PORTK = PORTK & ~0x02; // low MSDelay(15); x = (command & 0x0F) << 2; // clear upper nibble of command // shift lower nibble to bits 5-2 of x PORTK = PORTK & ~0x3C; // clear PK5-PK2 PORTK = PORTK | x; // set PK5-PK2 to lower nibble of command // send high-low pulse to PK1 to enable latching of command PORTK = PORTK | 0x02; // high MSDelay(5); PORTK = PORTK & ~0x02; // low MSDelay(15); } //The flash function definition: void flash(void) { unsigned char inumber; unsigned int num; inumber = 0x80; for(num=0;num<8;num++) { PORTB = inumber; inumber = inumber >> 1; MSDelay(100); } //The blink function definition: void blink(unsigned char number) { unsigned int total; for(total=0;total { PORTB = 0xFF; MSDelay(500); PORTB = 0x00; MSDelay(500); } // serial transmit function void SerTx0(unsigned char c) { while((SCI0SR1 & 0x80) == 0); SCI0DRL = c; } QUESTION IS what is the question should be for this cooding ? ( C langauge )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
