Write a program in code warrior in assembly language to make a Dragon12-plus2 bo
ID: 3697194 • Letter: W
Question
Write a program in code warrior in assembly language to make a Dragon12-plus2 board do something interesting. Such as a calculator, light show, play music, etc. open ending programming assignment. Write a program in code warrior in assembly language to make a Dragon12-plus2 board do something interesting. Such as a calculator, light show, play music, etc. open ending programming assignment. Write a program in code warrior in assembly language to make a Dragon12-plus2 board do something interesting. Such as a calculator, light show, play music, etc. open ending programming assignment.Explanation / Answer
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#define DATA PORTK
#define CTRL PORTK
#define RS 0x01
#define EN 0x02
void COM1(unsigned char);
void DAT1(unsigned char);
void DELAY(unsigned int);
void main(void)
{
DDRK = 0xFF;
COM1(0x33); //reset sequence provided by data sheet
DELAY(1);
COM1(0x32); //reset sequence provided by data sheet
DELAY(1);
COM1(0x28); //Function set to four bit data length
//2 line, 5 x 7 dot format
DELAY(1);
COM1(0x06); //entry mode set, increment, no shift
DELAY(1);
COM1(0x0E); //Display set, disp on, cursor on, blink off
DELAY(1);
COM1(0x01); //Clear display
DELAY(1);
COM1(0x80); //set start posistion, home position
DELAY(1);
DAT1('H');
DELAY(1);
DAT1('E');
DELAY(1);
DAT1('L');
DELAY(1);
DAT1('L');
DELAY(1);
DAT1('O');
for(;;); //stay here
}
void COM1(unsigned char command)
{
unsigned char x;
x = (command & 0xF0) >> 2; //shift high nibble to center of byte for Pk5-Pk2
DATA =DATA & ~0x3C; //clear bits Pk5-Pk2
DATA = DATA | x; //sends high nibble to PORTK
DELAY(1);
CTRL = CTRL & ~RS; //set RS to command (RS=0)
DELAY(1);
CTRL = CTRL | EN; //rais enable
DELAY(5);
CTRL = CTRL & ~EN; //Drop enable to capture command
DELAY(15); //wait
x = (command & 0x0F)<< 2; // shift low nibble to center of byte for Pk5-Pk2
DATA =DATA & ~0x3C; //clear bits Pk5-Pk2
DATA =DATA | x; //send low nibble to PORTK
CTRL = CTRL | EN; //rais enable
DELAY(5);
CTRL = CTRL & ~EN; //drop enable to capture command
DELAY(15);
}
void DAT1(unsigned char data)
{
unsigned char x;
x = (data & 0xF0) >> 2;
DATA =DATA & ~0x3C;
DATA = DATA | x;
DELAY(1);
CTRL = CTRL | RS;
DELAY(1);
CTRL = CTRL | EN;
DELAY(1);
CTRL = CTRL & ~EN;
DELAY(5);
x = (data & 0x0F)<< 2;
DATA =DATA & ~0x3C;
DATA = DATA | x;
CTRL = CTRL | EN;
DELAY(1);
CTRL = CTRL & ~EN;
DELAY(15);
}
void DELAY(unsigned int itime)
{
unsigned int i; unsigned int j;
for(i=0;i<itime;i++)
for(j=0;j<4000;j++);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.