Sunteți pe pagina 1din 2

Laboratory 2

Reading and Writing Using RAM


NAME: Trupal Patel
CLASS: ECE 372 Section - 2
DATE: September 8, 2015
OBJECTIVE: Write a phrase Do not feed the ELVIS to RAM and then read it from RAM to
display on a LCD screen on the ELVIS board.
EQUIPMENT USED: ELVIS Board, Computer
PROCEDURE: Write C code that store the phrase Do not feed the ELVIS to Ram starting at
the address 3F3F then read it and print it to the LCD display on the ELVIS board.
DESCRIPTION OF CODE: The code initializes the local variables needs for storing the string
and incrementing through the string and the LCD display. Then the for loop stores the string in to
RAM starting at the address 0x3F3F incrementing by the size of a character using the function
_P(address) provided by the lab manual. Then the code jumps in to infinite do loop where the
LCD display is cleared. For loop is started which runs till the variable k reaches 22 and the
screen is cleared every eight increment of k. then the increment variable j is calculated using the
sizeof function then the character is read from address and put on the LCD screen using the
function LCDPutChar(). Then a delay is added before every clearing of the screen using tow for
loops that do nothing.
DATA: N/A
OBSERVATIONS AND DISCUSSIONS: The phrase Do not feed the ELVIS was stored in
RAM and then later read from the RAM then displayed on the LCD display on the ELVIS board
eight characters at a time. The code was written to continually print the aforementioned phrase to
the LCD display. While testing the code we discovered that the display need a delay be for
clearing the characters otherwise the code runs to fat to be seen and truly tested. To add this
delay tow for loops were added to make the processer spend time incrementing through them and
provide time to view the phrase being printed.
QUESTIONS: N/A
CONCLUSIONS: in conclusion the lab teaches how to use the provided _P() function to access
the RAM using specific addresses. How to work with the limited LCD display on the ELVIS
board and how the output to the display needs to be set up.
This report is accurate to the best of my knowledge and is a true representation of my
laboratory results.

C- CODE:
/* ALWAYS INCLUDE THESE LINES OF CODE */
#include <hidef.h>
/* common defines and macros */
#include <mc9s12dt256.h> /* derivative information */
#include "pbs12dslk.h" /* I/O definitions and init routines */
#include "lcd.h"
/* LCD definitions and init routines */
#pragma LINK_INFO DERIVATIVE "mc9s12dt256"
/* END ALWAYS INCLUDE THESE LINES OF CODE */
#define _P(ADDRESS) *(unsigned char volatile *)(ADDRESS)
/* Global Variables */
long int count = 1;
int divisor = 0;
int LCD_refresh = 5;
int LED_SPEED = 100;
/* End Global Variables */
void main(void){
unsigned char a[]=" Do not feed the ELVIS";
int j,i,k,y,z;
int b;
LCDInit();
for(i=0;i<21;i++){
j=i*sizeof(unsigned char);
_P(0x3F3F+j) = a[i];
}
do{
b=0;
LCDClearDisplay();
for(k=0;k<22;k++,b++){
if (k%8==0) {
LCDClearDisplay();
}
j = b * sizeof(unsigned char);
LCDPutChar(_P(0x3F3F+j));
if (k % 8 == 7 || k==21) {
for(y=0;y<500;y++){
for(z=0;z<500;z++){}
}
}
}
}while(1);
}

S-ar putea să vă placă și