E.E Electrical Engineering Design

Size: px
Start display at page:

Download "E.E Electrical Engineering Design"

Transcription

1 E.E Electrical Engineering Design Final Report Submitted to: Dr. Seok-Bum Ko Lecture Section: 2 Prepared by: Cory Anderson Jon Lovering Submission Date: Tuesday April 12 th, 2005

2 Table of Contents MOTOROLA 68HC11 PROJECTS... 1 Microcontroller tutorial...1 Pre-lab...1 Objective...1 Procedure...1 Questions & Answers...6 Two example operations of the 68HC11 microcontroller...6 Pre-lab...6 Objective...7 Procedure...7 Questions & Answers...9 An example C Cross-compiler for the 68HC Pre-lab...9 Objective...9 Procedure...9 Questions & Answers...16 An example difference between the Intel 8051 and the Motorola 68HC11 microcontrollers...17 Pre-lab...17 Objective...17 Procedure...17 Questions & Answers...18 FINAL PROJECT Introduction...18 Implementation...18 Hardware Diagrams...22 Program...23 Conclusions...39 i

3 1. Motorola 68HC11 Projects 1.1. Microcontroller tutorial Pre-lab While no previous knowledge of Motorola s 68HC11 microcontroller is necessary for this tutorial, some familiarity of its components would help a great deal in order to completely understand all aspects of this tutorial. The following components are required in order to complete this tutorial: Motorola 68HC11 microcontroller with accompanying serial cable A Window s based personal computer equipped with the AsmIDE software The tutorial contains numerous screenshots of the very same steps to be followed as they would appear directly on the computer screen. This has been done to ensure the ease of this tutorial, so as to focus the objective of this exercise on learning more about the operation of the 68HC11, not on attempting to decipher instructions Objective After having completed this tutorial, the student will be able to interface the microcontroller with a computer, upload a program into the microcontroller, and realize the program s execution. This tutorial will introduce the elementary operation of port B. In this example, port B will operate the on-board LEDs Procedure 1. Attach the appropriate end of the supplied serial cable to the 68HC11. Similarly, attach the opposing end to the LPT1 port on the personal Computer. 2. Plug the supplied AC-DC converter into a nearby wall outlet, and attach the opposing end barrel plug into the appropriate socket on the microcontroller. 3. Search for the AsmIDE software on the computer. Activate the software. The following two pictures show the AsmIDE icon on the Windows 98 and what the program looks like when it is opened. 1

4 2

5 4. At the top of the screen choose file open. 5. Locate the file program1, highlight it, and click the open button. A few lines of assembly code should be visible in the main window. The following two slides illustrate this step. 3

6 The assembly code used for this section is as follows: portb: equ $1004 ;alias the memory address of port b to symbole portb SPEED: equ $ffff ;alias the speed of the delay loop to SPEED Org $C000 ;set the start location of the program. loop: ldaa #$ff ;load accumulator a with ff staa portb ;place ff on port b jsr delay ;delay ldaa #$00 ;load accumulator a with 00 staa portb ;place 00 on port b jsr delay ;delay jmp loop ;repeat delay: ldx #SPEED ;load x with the speed symbol dly: dex ;decrement x nop ;no opperation nop bne dly ;if x is not zero, loop again rts ;return 6. At the top of the screen choose build assemble. You will then see the some text scrolling at the bottom of the window in the messages tab indicating that the asm file is assembling. The following two slides illustrate this step. 4

7 7. Now click the terminal tab at the bottom of the screen. It is located directly beside the messages tab. You will see some text referring to the current version of the BUFFALO monitor. Click the mouse in the terminal window, and press enter. Once enter has been pressed you should see a > symbol. 8. Now type load t after the > symbol, and press the enter key. 5

8 9. At the top of the screen choose build download. When the download of the program into the microcontroller is complete, you will see the word done in the terminal. 10. Now type g C000 in the terminal after the > symbol. You should now see the program in execution on the microcontroller Questions & Answers 1. What am I seeing on the microcontroller? You are watching simple activation of all the outputs on port b, followed by the deactivation of the same outputs. This is easily verified by the repeated turning on and off of the LEDs Two example operations of the 68HC11 microcontroller Pre-lab Just as the previous section, there is no formal pre-lab required for this section. As the following two examples demonstrate different components of the Motorola instruction set, some knowledge of the hardware and its operation would be an asset; but is not necessary. 6

9 Objective As described, these simple programs will demonstrate the operation of the some of the 68HC11 s instruction set. The first program will focuses on the logical shifting instructions inherent to the microcontroller, while the second program exercises its XOR instructions Procedure The procedure for this section is identical to that of section with only two minor variations. Instead of working with program1, we will first execute program2a, followed by program2b. The assembly code for program2a is as follows: portb: equ $1004 ;alias the memory address of port b to symbole portb SPEED: equ $ffff ;alias the speed of the delay loop to SPEED start: org $C000 ;set the start location of the program. buildright: ldaa #$01 ;load accumulator a with 01 jsr display ;display ldaa #$03 ;load accumulator a with 03 (binary 11) jsr display ldaa #$07 ;load acca with 07 (binary 111) jsr display startloopleft: ldx #$0008 ;load x with 8 loopleft: lsla ;shift a left 1 place jsr display dex ;decrement x bne loopleft ;repeat 8 times buildleft: ldaa #$80 ;load acca with 80 (binary ) jsr display ldaa #$C0 ;load acca with C0 (binary ) jsr display ldaa #$E0 ;load acca with E0 (binary ) jsr display startloopright: ldx #$0008 ;load x with 8 loopright: lsra ;shift a right 1 place jsr display dex ;decrement x bne loopright ;repeat 8 times jmp start end display: staa portb ;store a on portb jsr delay ;delay rts 7

10 delay: pshx ldx #SPEED ;load x with the speed symbol dly: dex ;decrement x nop ;no opperation nop bne dly ;if x is not zero, loop again pulx rts ;return The assembly code for prgram2b is as follows: portb: equ $1004 ;alias the memory address of port b to symbole portb SPEED: equ $ffff ;alias the speed of the delay loop to SPEED Org $C000 ;set the start location of the program. main: ldaa #$ff ;load accumulator a with ff ldx #$0003 ;load i with 3 staa portb ;place a on portb jsr delay ;delay loop1: lsla ;shift a left 1 place eora #$FF ;exor a with FF * * ^ = * ^ = staa portb ;display jsr delay dex ;decrement x bne loop1 ;repeat 5 times ldaa #$ff ;load accumulator a with ff ldx #$0003 staa portb ;place a on portb jsr delay ;delay loop2: lsra ;shift a right 1 place eora #$FF ;exor a with ff * * ^ = * ^ = staa portb jsr delay dex ;decrement x bne loop2 ;repeat 5 times jmp main ;repeat delay: pshx ldx #SPEED ;load x with the speed symbol dly: dex ;decrement x nop ;no opperation nop 8

11 bne dly ;if x is not zero, loop again pulx rts ;return Questions & Answers 1. Will I be able to tell the difference from the initial program and the two example programs? Yes. All three programs are distinct in that each of their outputs will be quite noticeably different An example C Cross-compiler for the 68HC Pre-lab This section of the tutorial requires that the personal computer be equipped with the EmbeddedGNU software for the Motorola 68HC11. This program will allow the user to simply write C code, rather than assemble code, so as to realize a desired function on the microcontroller Objective This section will show that programs can also be realized on the Motorola 68HC11 by using the higher level C programming language. While there are numerous advantages to programming with assembly code, such as time critical loops and interrupts; programming in a higher level language, for the most part, can take achieve the same results in a much shorter period of time. This section will show that the assembly program found in section can be reproduced in entirety by authoring C code Procedure 1. Search for the EmbeddedGNU software on the computer. Activate the software. The following slide will illustrate the resulting window. 9

12 2. At the top of the screen choose file open project or file. 10

13 3. Locate the file Project1, highlight it, click the open button. The following two slides illustrate this step. 11

14 4. You will now be looking at program code written in the C language. This program will execute the identical task as demonstrated in section 1.1. At the top of the screen choose build make. The code used in this section is as follows: #include <stdio.h> #include <string.h> int main(void); void delay(void); #define SPEED 0xffff #define PORTB *(unsigned char volatile *)(0x1004) /* i/o port b */ int main() //loop forever while (1) PORTB = 0xff; //put ff on portb delay(); //delay PORTB = 0x00; //put 00 on port b delay(); return 0; /* not used */ //delay void delay() unsigned short int i; for (i = 0; i < SPEED; i++) /* nothing */ 12

15 5. A window will pop up showing that the files are compiling. 6. A second window will be shown once the make has been completed. 13

16 7. Click Ok on the above window to continue. You will then arrive at the following slide. 8. At the top of the screen choose build download. 14

17 9. At the top of the screen choose options project options. A small window will open. 10. Now click Edit Profile. A second window will open. 15

18 11. Take note of the number in the text field. This is number represents the start location of the program. In this case the number is Now click OK to close the window. Then click OK again to close the previously opened window. 13. Now click the Terminal tab at the bottom of the screen. 14. Then type g 9000 (where 9000 is the number found in step 11). The microcontroller will now be running the C program. It should be noted that the operation carried out by the unit should be in every way identical to the observed output of section Questions & Answers 1. Are programming in assembly code and C code the only options? They are the most common options, but you are only limited by the chosen crosscompiler. If you are able to find 68HC11 compatible programs that are able to compile and link other programming languages, you would have the freedom to choose the language of your choice. 2. Is there only one available C cross-compiler for the 68HC11? No, there are other choices. This program, however, seemed an excellent choice for this tutorial as it possessed all of the required functions, and was free of charge. 16

19 1.4. An example difference between the Intel 8051 and the Motorola 68HC11 microcontrollers Pre-lab For this portion of the tutorial it is important to understand a specific hardware difference between Intel s 8051 and Motorola s 68HC11 microcontrollers. The Motorola unit is equipped with two 8-bit registers that can be treated as one 16-bit register. The Intel unit, however, cannot combine the use of its registers in any way, limiting it to a total resolution of 8 bits Objective It has been clearly stated in this section s Pre-lab that the 8051 simply cannot work with 16-bit values, and the following procedure will show this statement to be true. This experiment will simply place a 16-bit value into the 68HC11 s stack. We will then pop two 8-bit values off of the stack, and find that we will have our original 16-bit value. The Intel system, however, simply does not accept the code, and will not load it. This is due to its inability to properly deal with 16-bit values Procedure Again, following the same procedure in section 1.1.3, we will load the 68HC11 with program4. Its assembly code is as follows: portb: equ $1004 ;alias the memory address of port b to symbol portb SPEED: equ $ffff ;alias the speed of the delay loop to SPEED Org $C000 ;set the start location of the program. loop: ldaa #$00 staa portb ldy #$1881 ;load x with AABB pshy ;push x to the stack pula ;pull a (one byte of x) from the stack and put on portb staa portb jsr delay pula ;pull a (the other byto of x) from the stack and put on portb staa portb jsr delay jmp loop end delay: pshx ldx #SPEED ;load x with the speed symbol dly: dex ;decrement x 17

20 nop ;no opperation nop bne dly ;if x is not zero, loop again pulx rts ;return Make note of the results found on port b (the LEDs). You can now attempt to run the run the very same program in the 8051, but you will find that the program will not even load. It cannot handle 16-bit values and therefore states that there is an error in the code Questions & Answers 1. Does this mean that the 68HC11 cannot handle 8-bit numbers? No; not at all. The 68HC11 is fully capable of handling any value less than a 16- bit resolution. 2. Final Project 2.1. Introduction Our final project involved the design and realization of a fully functional 12/24 hour clock. While at first the problem definition called for the clock solely, the design requirements changed after meeting with the customer. We included other features such as backlighting, alarm, and current date display. We were able to come up with a successful design in the time allotted. Our results were as expected: a fully functioning unit, in line with the required specifications Implementation Our first step was to come up with a very basic block diagram of the entire system. We concluded that there were only a few major blocks that would comprise our entire design. They were the inputs (buttons), outputs (liquid crystal display), and the Intel 8051 microcontroller itself. We decided to split the block diagram for the controller unit into two separate blocks: the controller itself, and its internal clock. Because our design was going to weigh heavily on the clock, we felt it would be easier to consider a separate entity. The following pages will show various black diagrams that were vital in designing the final code that was implemented to realize this design. Attempting to write the code without these basic diagrams would have resulted in certain failure. After having visualized the problem this way, writing the code was much easier, and was organized in a fashion that made sense. 18

21 After establishing a central block diagram outlining the system we wanted to create, we then began to create block diagrams for each component in the system block diagram. We began with the main inputs, the buttons: It was now easier to understand what function we wanted each button to execute. We continued by drawing a block diagrams as to how the microcontroller would execute the setting of each function: 19

22 As this function was extremely complicated, it could be fit into this document in its entirety without being severely compressed. As such, it may be difficult to read. After this difficult diagram had been, the next step was to ensure that the interrupts were set-up properly to both keep time, and to take care of a button press: 20

23 All that remained was to accurately map out how all of the appropriate information would be displayed to the LCD screen: And also to ensure that the time was continually updated: 21

24 After we had mapped out how our design was going to function, we were able to use these block diagrams to organize and formulate a C language program to realize the design. We enjoyed successful results Hardware Diagrams Besides the microcontroller itself, we did employ the use secondary components such as a backlit liquid crystal display, and external flip-flops to act as debouncers for the input buttons: The flip-flops are shown on the far left of the schematic, while the display is shown on the far right of the diagram. We were also able to refine our design so that a much smaller and more easily produced product could be mass manufactured: 22

25 This final design can easily be fed into computer controlled robots, and production of this product could begin Program The following is the complete code written in the C language to run the main part of our program: #define MICROCONTROLLER_AT89S53 #include <mcs51reg.h> #include <stdio.h> //#define DEBUG //Initial condition settings #define TICKSTOSEC 100 #define SSEC 00 #define SMIN 30 23

26 #define SHOUR 18 #define SDAY 03 #define SMONTH 4 #define SYEAR 2005 #define SALHOUR 00 #define SALMIN 00 #define SAL 0 #define SFUNC 1 #define SHRMINSEC 1 #define S_ #define SENTMIN 10 #define TIMER0_TICKS //these are bit flags set by interrupts volatile bit update_next; volatile bit set_mode; //the defines set the symbols for the input switches #define set_s P1_0 #define display_s P1_1 #define _1224_S P1_2 #define func_s P1_3 #define FFCLOCK P1_7 #define ALARM_RING P1_6 //All of the internal values volatile unsigned char hour; volatile unsigned char minute; volatile unsigned char second; volatile unsigned char day; volatile unsigned char month; volatile int year; volatile unsigned char alarm_hour; volatile unsigned char alarm_minute; volatile bit alarm_on; //sentinel is a special variable used for various counting things volatile unsigned char sentinel; //various internal settings. volatile bit hrminsec; volatile bit _1224; volatile unsigned char func; // 30 days has september, april, june, and noverember //jan, feb, march, april, may, june, july, august, septemember, october, //november, decemeber char max_days[] = 00, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31; //symbolistic constants #define TIME 1 24

27 #define ALARM 2 #define DATE 3 #define TRUE 1 #define FALSE 0 /* This interrupt is called when ever there is an positive negative going edge on EX0. */ void E0interrupt(void) interrupt 0 using 0 sentinel = 0; //When a button is and the alarm is running, stop it if (ALARM_RING == 0x1) alarm_on = FALSE; ALARM_RING = 0x0; //if the button is the display button, change the display type if (display_s) hrminsec =!hrminsec; //if the button is the 12/24 button change the 12/24 mode if (_1224_S) _1224 =!_1224; //if the button is the function button, change to the next function. //Special case: the next function is > DATE (beyond last function type) then //loop back if (func_s) if(++func > DATE) func = TIME; //if the button is the set mode button, then assert set mode if (set_s) set_mode = TRUE; return; /* 25

28 This function deals with an overflow of timer 0. This function has three responsibilities: 1) determine if the display needs updating, and assert the flag to do so 2) determine if the time needs updating, and assert the flag to do so 3) toggle to slow clk (used for hardware debounce) */ void t0overflow (void) interrupt 1 using 0 static char wait_time = 0; //This embedded ASM resets the timer. This structure is very robust, and //can handle an interrupt being late. _asm clr TR0 mov A, TL0 add A, #(-(TIMER0_TICKS - 7)) & 0xFF mov TL0, A mov A, TH0 addc A, #((-(TIMER0_TICKS - 7)) >> 8) & 0xFF mov TH0, A setb TR0 _endasm; //Run the slow clk //FFCLOCK = 1; //FFCLOCK = 0; FFCLOCK =!FFCLOCK; if(++wait_time >= TICKSTOSEC) wait_time = 0; update_next = TRUE; /*max day is used to correctly handle the days of the months (especially February on leap years)*/ char max_day(void) if (month == 2) if (year % 4 == 0 && (year % 100!= 0 year % 400 == 0)) return 29; else return 28; return max_days[month]; 26

29 /*Update time has two functions: 1) reset mode if the inactive time is greater than 5 seconds 2) increment the time (and date)*/ void update_time (void) //increment the sentinel and if it is greater than 5, return to TIME mode, //and deactivate set mode. sentinel++; if (sentinel >= SENTMIN) sentinel = 0; func = TIME; set_mode = FALSE; //This if block cascades, if ++(blank) > (blanks max) then update the next //largest value after (blank) if (++second >= 60) second = 0; if (++minute >= 60) minute = 0; if (++hour >= 24) hour = 0; if (++day > max_day()) day = 1; if (++month > 12) month = 1; year++; update_next = FALSE; return; /* display has only one function, display correctly the right information. There is a hierarchy of cases: FUNCTION 12/24 Hour/Min/Sec Mode */ void display(bit mode) char hour12 = 0; 27

30 bit pm = 0; #ifdef DEBUG func = SFUNC; #endif //if the function is TIME if (func == TIME) //12/24? if (_1224) /* this block determines 12 hour time. if the hour is greater than 12, the mod of the hour is placed in hour12. */ hour12 = hour; pm = 0; if (hour12 > 12) hour12 = hour % 12; pm = 1; //Special case: in tw if (hour12 == 0) hour12 = 12; if (hrminsec) //print the time: mode is handled by a trinarry statement in the //printf, as is am/pm. printf("%stime\f%02i:%02i:%02i %s\n", (mode? "SET " : ""), hour12, minute, second, (pm? "pm" : "am")); else //print, no seconds printf("%stime\f%02i:%02i %s\n", (mode? "SET " : ""), hour12, minute, (pm? "pm" : "am")); else if (hrminsec) //print 24 hour, /w seconds printf("%stime\f%02i:%02i:%02i\n", (mode? "SET " : ""), hour, minute, second); else //print 24 hour, /wo seconds printf("%stime\f%02i:%02i\n", (mode? "SET " : ""), hour, minute); 28

31 //Function is alarm. All code like time. //Special case: alarm on / off handled by triarry statement. if (func == ALARM) if (_1224) hour12 = alarm_hour; pm = 0; if (alarm_hour > 12) hour12 = alarm_hour % 12; pm = 1; if (hour12 == 0) hour12 = 12; printf("%salarm\f%02i:%02i %s %s\n", (mode? "SET " : ""), hour12, alarm_minute, (pm? "pm" : "am"), (alarm_on? "on" : "off")); else printf("%salarm\f%02i:%02i %s\n", (mode? "SET " : ""), alarm_hour, alarm_minute, (alarm_on? "on" : "off")); //function is date if (func == DATE) //print the date printf("%sdate\f%02i/%02i/%04i\n", (mode? "SET " : ""), day, month, year); return; /* Set the time, alarm, or date */ void setmode (void) char set_sent = 0; /* This loop ensures that the set switch is held for 2 seconds Time continues to count */ printf("set\n"); while (set_sent < 2) while (!update_next && set_s) update_time(); if (set_s) 29

32 else set_sent++; return; //turn off interrupts, for great justice EX0 = 0; //Ensure the set_s is released prior to entering the set loop printf("release Set\n"); while (set_s) if (update_next) update_time(); //set just for insurance. Technically guaranteed at this point. set_mode = TRUE; sentinel = 0; //while we're still in set mode: this loop will break if the user turns off //set mode (holds Set_S for 2 seconds) or the sentinel turns of set mode while (set_mode) //if the current function is time if (func == TIME) //while we are still in set_mode, and the set_s isn't being pressed while (set_mode &&!set_s) //if display_s is pressed, then reset the sentinel and update //the hour. if (display_s) sentinel = 0; if (++hour >= 24) hour = 0; display(1); //ensure that display_s is released, (8)time keeps ticking, //ticking, ticking, into the future (8) while (display_s) if (update_next) update_time(); display(1); 30

33 //if the 12/23 switch is pressed, then reset the sentinel, and //increment the minute if (_1224_S) sentinel = 0; if (++minute >= 60) minute = 0; display(1); //ensure that 12/24 is release. Again with the time thing while (_1224_S) if (update_next) update_time(); display(1); //pesky time if (update_next) update_time(); display(1); //if we're done, then 0 second. second = 0; //if the function is alarm, we handle it just like time, but change the //variable names. //Special case: alarm on / off is toggled by func_s if (func == ALARM) while (set_mode &&!set_s) if (display_s) sentinel = 0; if (++alarm_hour >= 24) alarm_hour = 0; display(1); while (display_s) if (update_next) update_time(); display(1); 31

34 if (_1224_S) sentinel = 0; if (++alarm_minute >= 60) alarm_minute = 0; display(1); while (_1224_S) if (update_next) update_time(); display(1); if (func_s) sentinel = 0; alarm_on =!alarm_on; display(1); while (func_s) if (update_next) update_time(); display(1); if (update_next) update_time(); display(1); //if the function is date. //switches do different dances, but the logic is the same. //display_s : days //12/24: months //func_s: years **years will not advance beyond 2030 too bad** if (func == DATE) while (set_mode &&!set_s) if (display_s) 32

35 sentinel = 0; if (++day > max_day()) day = 1; display(1); while (display_s) if (update_next) update_time(); display(1); if (_1224_S) sentinel = 0; if (++month > 12) month = 1; display(1); while (_1224_S) if (update_next) update_time(); display(1); if (func_s) sentinel = 0; if (++year > 2030) year = 2005; display(1); while (func_s) if (update_next) update_time(); display(1); if (update_next) update_time(); 33

36 display(1); /* This loop ensures that the set switch is held for 2 seconds */ printf("set EXIT\n"); set_sent = 0; while (set_sent < 2) while (!update_next && set_s); update_time(); if (set_s) set_sent++; else break; if (set_sent >= 2) set_mode = FALSE; //turn back on interrupts EX0 = 1; display(0); return; /* The heart: set up all of the functions, and then wait. */ void main(void) //set the timer up, and start it TL0 = TIMER0_TICKS & 0xFF; TH0 = (TIMER0_TICKS >> 8) & 0xFF; TMOD = 0x01; TR0 = 1; EA = 1; //Enable interrupts IT0 = 1; //Make EX0 edge triggered EX0 = 1; //Enable X0 (External interrupt) ET0 = 1; //Enable TO (Timer interrupt) //Force Alarm ring (the pin) low ALARM_RING = 0x0; 34

37 //Set the function to the initialization function func = SFUNC; //Set time to the initialization values second = SSEC; minute = SMIN; hour = SHOUR; day = SDAY; month = SMONTH; year = SYEAR; //set the alarm to the initialization values alarm_hour = SALHOUR; alarm_minute = SALMIN; alarm_on = SAL; //set the display thingies to initialization values hrminsec = SHRMINSEC; _1224 = S_1224; //No time or display updates (yet) update_next = FALSE; //Done for(;;) //if the time needs updating: do it, and update the display if (update_next == TRUE) update_time(); display(0); //set mode? do it if (set_mode == TRUE) setmode(); //if the alarm is on, then should it go off? if (alarm_on == TRUE) if (alarm_hour == hour) if(alarm_minute == minute) ALARM_RING = 0xF; 35

38 There was also additional code needed for the proper operation of the LCD on the 8051: #include <8051.h> #include "lcd.h" #define LCD_ENABLE P3_7 #define LCD_RS P0_0 /* 0=Command 1=Data */ #define LCD_RWBAR P0_1 /* 0=Write 1 = Read */ #define LCD_PORT_BUSY_FLAG P0_7 #define LCD_DATA_PORT P0 #define LCD_DATA_MASK 0xF0 #define LCD_DATA_SHIFT 4 #pragma CALLEE-SAVES LCD_Delay, LCD_Wait /* * Delay specified number of 100 usec intervals * Assumes a 12 MHz clock...and a smart compiler! */ static void LCD_Delay (volatile unsigned char husec) do volatile unsigned char i = 50; do while (--i); while (--husec); static void LCD_Wait (void) bit bf; LCD_RS = 0; LCD_RWBAR = 1; LCD_DATA_PORT = LCD_DATA_MASK; do LCD_ENABLE = 1; bf = LCD_PORT_BUSY_FLAG; LCD_ENABLE = 0; LCD_ENABLE = 1; LCD_ENABLE = 0; while (bf); /* * Send a data character to the LCD */ void LCD_SendData (char c) 36

39 LCD_Wait (); LCD_RS = 1; LCD_RWBAR = 0; LCD_DATA_PORT &= ~LCD_DATA_MASK; LCD_DATA_PORT = c & LCD_DATA_MASK; LCD_ENABLE = 1; LCD_ENABLE = 0; LCD_DATA_PORT &= ~LCD_DATA_MASK; LCD_DATA_PORT = (c << LCD_DATA_SHIFT) & LCD_DATA_MASK; LCD_ENABLE = 1; LCD_ENABLE = 0; /* * Send a command byte to the LCD */ void LCD_SendCmd (char cmd) LCD_Wait (); LCD_RS = 0; LCD_RWBAR = 0; LCD_DATA_PORT &= ~LCD_DATA_MASK; LCD_DATA_PORT = cmd & LCD_DATA_MASK; LCD_ENABLE = 1; LCD_ENABLE = 0; LCD_DATA_PORT &= ~LCD_DATA_MASK; LCD_DATA_PORT = (cmd << LCD_DATA_SHIFT) & LCD_DATA_MASK; LCD_ENABLE = 1; LCD_ENABLE = 0; /* * Initialize LCD for 4-bit data bus */ void LCD_Init (void) LCD_DATA_PORT &= ~LCD_DATA_MASK; LCD_DATA_PORT = (0x3 << LCD_DATA_SHIFT); LCD_RS = 0; LCD_RWBAR = 0; LCD_ENABLE = 0; LCD_Delay (150); LCD_ENABLE = 1; LCD_ENABLE = 0; LCD_Delay (41); LCD_ENABLE = 1; LCD_ENABLE = 0; LCD_Delay (1); LCD_ENABLE = 1; LCD_ENABLE = 0; LCD_Delay (41); 37

40 LCD_DATA_PORT &= ~LCD_DATA_MASK; LCD_DATA_PORT = (0x2 << LCD_DATA_SHIFT); LCD_ENABLE = 1; LCD_ENABLE = 0; LCD_SendCmd (0x28); /* 4-bit, 2-line, 5x8 */ LCD_SendCmd (0x08); /* Display off, cursor off, blink off */ LCD_SendCmd (0x01); /* Clear display*/ LCD_SendCmd (0x02); /* Home Cursor */ LCD_SendCmd (0x06); /* Increment cursor, no shift */ LCD_SendCmd (0x0C); /* Display on, cursor off, blink off */ /* * I don't know why the following loop is necessary, but without * the loop (even with just the LCD_Delay) the first character * displayed is gibberish. */ unsigned int i; for(i = 0 ; i < 1 ; i++) LCD_Delay (200); To accompany this C file is its header file: #pragma CALLEE-SAVES LCD_Init, LCD_Putchar, LCD_SendData, LCD_SendCmd void LCD_Init (void); void LCD_Putchar (char c); void LCD_SendData (char c); void LCD_SendCmd (char cmd); And lastly, another C file was needed to take care of character placement: #include "lcd.h" /* * Special values for `character position' */ #define POS_INIT 255 #define POS_END 254 #define POS_NEWLINE 253 /* * Supply putchar if user code has not done so. */ void putchar (char c) static unsigned char pos = POS_INIT; if (pos == POS_INIT) LCD_Init (); pos = POS_END; if (c == '\r') 38

41 pos = 0; else if (c == '\n') pos = POS_END; else if (c == '\f') pos = POS_NEWLINE; else if (pos == POS_END) LCD_SendCmd (0x1); pos = 0; else if (pos == POS_NEWLINE) LCD_SendCmd (0xC0); pos = 16; if (pos < 16) LCD_SendCmd (0x80 + pos); else if (pos < 32) LCD_SendCmd (0x80 + 0x40 + pos - 16); LCD_SendData (c); pos++; 2.5. Conclusions While the idea of designing a clock seemed rather elementary at first, the final design proved to be quite challenging. Much more programming was needed than originally had been anticipated, and conversely, less hardware than anticipated. We had difficulty, in particular, with ensuring that our clock was able to keep time within given parameters. For our prototype design, we had decided that a time variation of ±5 minutes per 24 hour period would be considered a successful design. We found, however, that our design was losing close to 5 minutes in less than 10 hours. After going over the code several times, very minor glitches were found, and repaired. The design is now accurate to within 7 seconds per 24 hour period a dramatic improvement. There are some significant design flaws, however. The back-lighting that we chose for this design would not be feasible for mass-production. We found that when the backlight is at its maximum intensity, it drew far too much current to be considered an efficient product. This however, is the only major change that we would consider making to this product, as the remainder functioned well within our expectations. Additionally, we would also like to have utilized the 68HC11 for this design, but only discovered a good C cross-compiler for the device after much of the design was complete for the The Motorola device had many useful attributes for our design. 39

Using the stack and the stack pointer

Using the stack and the stack pointer Using the stack and the stack pointer o The Stack and Stack Pointer o The stack is a memory area for temporary storage o The stack pointer points to the last byte in the stack o Some instructions which

More information

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7 ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume LECTURE 7 Reading Assignments Reading assignments for this week and next

More information

Programming the Motorola MC68HC11 Microcontroller

Programming the Motorola MC68HC11 Microcontroller Programming the Motorola MC68HC11 Microcontroller COMMON PROGRAM INSTRUCTIONS WITH EXAMPLES aba Add register B to register A Similar commands are abx aby aba add the value in register B to the value in

More information

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1 Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University What is Assembly Language? Assembly language is a programming language

More information

Introduction to Microcontrollers III

Introduction to Microcontrollers III Introduction to Microcontrollers III Timing Functions Delay5u.a11, Delay1m.a11 µp Laboratory #3 Data Entry : µp Laboratory #2 Hints Use the pushbutton routine from count.a11 or count_br.a11 (WAIT0 and

More information

Sample Problem Set #1

Sample Problem Set #1 Sample Problem Set #1 Notes: These problems are typical exam problems; most are drawn from previous homeworks and exams. This exam is open book, open notes. It may help to have a calculator. For partial

More information

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012) COE538 Lecture Notes: Week 3 1 of 11 COE538 Lecture Notes Week 3 (Week of Sept 17, 2012) Announcements My lecture sections should now be on Blackboard. I've also created a discussion forum (and anonymous

More information

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca. LCD Modules A common output display device used with low cost embedded systems is a character LCD display. The displays are available as complete modules with a standard microprocessor parallel interface.

More information

Exam I Review February 2017

Exam I Review February 2017 Exam I Review February 2017 Binary Number Representations Conversion of binary to hexadecimal and decimal. Convert binary number 1000 1101 to hexadecimal: Make groups of 4 bits to convert to hexadecimal,

More information

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (October 4, 2017) 1/18 538 Lecture Notes Week 5 Announements Midterm: Tuesday, October 25 Answers to last week's questions 1. With the diagram shown for a port (single bit), what

More information

538 Lecture Notes Week 1

538 Lecture Notes Week 1 538 Clowes Lecture Notes Week 1 (Sept. 6, 2017) 1/10 538 Lecture Notes Week 1 Announcements No labs this week. Labs begin the week of September 11, 2017. My email: kclowes@ryerson.ca Counselling hours:

More information

University of Florida EEL 4744 Fall 1998 Dr. Eric M. Schwartz

University of Florida EEL 4744 Fall 1998 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering 15 October 199 Professor in ECE 31-Dec-9 12:22 PM Page 1/ Instructions: Show all work on the front of the test papers. If you need more room, make a clearly

More information

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram History of the Microprocessor ECE/CS 5780/6780: Embedded System Design Chris J. Myers Lecture 1: 68HC12 In 1968, Bob Noyce and Gordon Moore left Fairchild Semiconductor and formed Integrated Electronics

More information

Chapter 1 Microprocessor architecture ECE 3120 Dr. Mohamed Mahmoud http://iweb.tntech.edu/mmahmoud/ mmahmoud@tntech.edu Outline 1.1 Computer hardware organization 1.1.1 Number System 1.1.2 Computer hardware

More information

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud. Chapter 1 Microprocessor architecture ECE 3130 Dr. Mohamed Mahmoud The slides are copyright protected. It is not permissible to use them without a permission from Dr Mahmoud http://www.cae.tntech.edu/~mmahmoud/

More information

Microcomputer Architecture and Programming

Microcomputer Architecture and Programming IUST-EE (Chapter 1) Microcomputer Architecture and Programming 1 Outline Basic Blocks of Microcomputer Typical Microcomputer Architecture The Single-Chip Microprocessor Microprocessor vs. Microcontroller

More information

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (Sept. 30, 2013) 1/15 538 Lecture Notes Week 5 Answers to last week's questions 1. With the diagram shown for a port (single bit), what happens if the Direction Register is read?

More information

Exam 1 Feb. 23, 25, 27?

Exam 1 Feb. 23, 25, 27? Exam 1 Feb. 23, 25, 27? You will be able to use all of the Motorola data manuals on the exam. No calculators will be allowed for the exam. Numbers Decimal to Hex (signed and unsigned) Hex to Decimal (signed

More information

Introduction to Microcontrollers

Introduction to Microcontrollers Motorola M68HC11 Specs Assembly Programming Language BUFFALO Topics of Discussion Microcontrollers M68HC11 Package & Pinouts Accumulators Index Registers Special Registers Memory Map I/O Registers Instruction

More information

MC9S12 Address Space

MC9S12 Address Space MC9S12 Address Space MC9S12 has 16 address lines MC9S12 can address 2 16 distinct locations For MC9S12, each location holds one byte (eight bits) MC9S12 can address 2 16 bytes 2 16 = 65536 2 16 = 2 6 2

More information

Introduction to the MC9S12 Hardware Subsystems

Introduction to the MC9S12 Hardware Subsystems Setting and clearing bits in C Using pointers in C o Program to count the number of negative numbers in an area of memory Introduction to the MC9S12 Hardware Subsystems o The MC9S12 timer subsystem Operators

More information

ECE 367 -Experiment #1 Fall 2012

ECE 367 -Experiment #1 Fall 2012 Due at the beginning of lab during week 3 (9/1/2012) Introduction ECE 367 -Experiment #1 Fall 2012 The goal of this experiment is the acquaint you with the Technological Arts nanocore12 microcontroller

More information

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly. More on Programming the 9S12 in C Huang Sections 5.2 through 5.4 Introduction to the MC9S12 Hardware Subsystems Huang Sections 8.2-8.6 ECT_16B8C Block User Guide A summary of MC9S12 hardware subsystems

More information

Introduction to Microcontrollers III

Introduction to Microcontrollers III Introduction to Microcontrollers III Timing Functions Delay5u.a11, Delay1m.a11 µp Laboratory #3 Data Entry : µp Laboratory #2 Hints Use the pushbutton routine from count.a11 or count_br.a11 (WAIT0 and

More information

Lecture 9 Subroutines

Lecture 9 Subroutines CPE 390: Microprocessor Systems Spring 2018 Lecture 9 Subroutines Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030 Adapted from HCS12/9S12

More information

8051 Microcontrollers

8051 Microcontrollers 8051 Microcontrollers Richa Upadhyay Prabhu NMIMS s MPSTME richa.upadhyay@nmims.edu March 8, 2016 Controller vs Processor Controller vs Processor Introduction to 8051 Micro-controller In 1981,Intel corporation

More information

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab By the end of Class Pseudo-code for Lab 1-2 due as part of prelab Homework #5 on website due before next class Outline Introduce Lab 1-2 Counting Timers on C8051 Interrupts Laboratory Worksheet #05 Copy

More information

CS/ECE 5780/6780: Embedded System Design

CS/ECE 5780/6780: Embedded System Design CS/ECE 5780/6780: Embedded System Design John Regehr Lecture 2: 68HC12 Architecture & Lab 1 Introduction Duff s Device void foo (int x, int *y, int *z) { switch (x % 8) { case 0: do { *y++ = *z++; case

More information

ECE 331: PC Lab 3 Stack and Subroutines

ECE 331: PC Lab 3 Stack and Subroutines ECE 331: PC Lab 3 Stack and Subroutines Professor Andrew Mason Michigan State University Rev: S11 p.1 Announcements Objectives Topics Outline Review starting and using ASM development environment Pushing

More information

538 Lecture Notes Week 3

538 Lecture Notes Week 3 538 Lecture Notes Week 3 (Sept. 16, 2013) 1/18 538 Lecture Notes Week 3 Answers to last week's questions 1 Write code so that the least significant bit of Accumulator A is cleared, the most significant

More information

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS ECE 3610 Test 2 Solution 1 of 7 PRINT LAST NAME: STUDENT NUMBER PRINT FIRST NAME: UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING DATE: Feb. 28, 11; TIME: 6:00-8:00 P.M. Term Test

More information

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE EE319 K Lecture 3 Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator University of Texas ECE Introduction (von Neumann architecture) processor Bus Memory Mapped I/O System Input Devices

More information

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING Experiment PCO: Principles of Computer Operation Location: Part I Lab., CYC 102. Objective: The objective is to learn the basic

More information

Coe538 Final Study Guide 2016 (Questions & Answers)

Coe538 Final Study Guide 2016 (Questions & Answers) Coe538 Study Guide 1 of 8 Coe538 Final Study Guide 2016 (Questions & Answers) This version contains questions AND answers. This study guide is meant to help you review coe538 and prepare for the final.

More information

Mark II Aiken Relay Calculator

Mark II Aiken Relay Calculator Introduction to Embedded Microcomputer Systems Lecture 6.1 Mark II Aiken Relay Calculator 2.12. Tutorial 2. Arithmetic and logical operations format descriptions examples h 8-bit unsigned hexadecimal $00

More information

Designing Your Own Soft Modules

Designing Your Own Soft Modules 4 Objectives Learn how to create circuit schematics with OrCAD Learn how to export a circuit from OrCAD as an EDIF netlist. Learn how to import an EDIF netlist into the FastChip library as a new soft module.

More information

C Language Programming, Interrupts and Timer Hardware

C Language Programming, Interrupts and Timer Hardware C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and

More information

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements. August 15, 2016 Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document Install SiLabs Instructions in Installing_SiLabs-SDCC- Drivers document Install SecureCRT On LMS, also

More information

EE 308 Spring A software delay

EE 308 Spring A software delay A software delay To enter a software delay, put in a nested loop, just like in assembly. Write a function delay(num) which will delay for num milliseconds void delay(unsigned int num) volatile unsigned

More information

Getting Started with the HCS12 IDE

Getting Started with the HCS12 IDE Getting Started with the HCS12 IDE B. Ackland June 2015 This document provides basic instructions for installing and using the MiniIDE Integrated Development Environment and the Java based HCS12 simulator.

More information

Outline. 2.8 Stack. 2.9 Subroutines

Outline. 2.8 Stack. 2.9 Subroutines Outline 21 Assembly language program structure 22 Data transfer instructions 23 Arithmetic instructions 24 Branch and loop instructions 25 Shift and rotate instructions 26 Boolean logic instructions 27

More information

Timers and interrupts

Timers and interrupts Timers and interrupts CSCI 255: Introduction to Embedded Systems Keith Vertanen Copyright 2011 Timers Overview Creating fixed pauses Calculate length of events Counts events Generate baud rate for serial

More information

C Language Programming, Interrupts and Timer Hardware

C Language Programming, Interrupts and Timer Hardware C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and

More information

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3. You will be able to use all of the Motorola data manuals on the exam.

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3. You will be able to use all of the Motorola data manuals on the exam. Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3 o Comparison of C and Assembly programs for the HC12 o How to compile a C program using the GNU-C compiler o Using pointers to access

More information

Introduction to Microcontrollers II

Introduction to Microcontrollers II Introduction to Microcontrollers II brset, brclr Indexed Addressing Example µp Laboratory #2 BUFFALO Assembling Code EECE 143 Digital Design Project Purpose: To allow students to design their own digital

More information

ECE/CE 3720: Embedded System Design

ECE/CE 3720: Embedded System Design Basic Components of Input Capture Slide 1 ECE/CE 3720: Embedded System Design Chris J. Myers Lecture 12: Input Capture Slide 3 Basic Principles of Input Capture Basic Principles of Input Capture (cont)

More information

Programming Book for 6809 Microprocessor Kit

Programming Book for 6809 Microprocessor Kit Programming Book for 6809 Microprocessor Kit Wichit Sirichote, wichit.sirichote@gmail.com Image By Konstantin Lanzet - CPU collection Konstantin Lanzet, CC BY-SA 3.0, Rev1.2 March 2018 1 Contents Lab 1

More information

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING. Principles of Computer Operation

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING. Principles of Computer Operation UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING Experiment PCO: Principles of Computer Operation Location: Part I Lab., CYC 102. Objective: The objective is to learn the basic

More information

ECET Chapter 2, Part 3 of 3

ECET Chapter 2, Part 3 of 3 ECET 310-001 Chapter 2, Part 3 of 3 W. Barnes, 9/2006, rev d. 10/07 Ref. Huang, Han-Way, The HCS12/9S12: An Introduction to Software and Hardware Interfacing, Thomson/Delmar. In This Set of Slides: 1.

More information

Lecture #4 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Monday, 25-Jan-2016

Lecture #4 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Monday, 25-Jan-2016 Lecture #4 Microcontroller Instruction Set 2 18-348 Embedded System Engineering Philip Koopman Monday, 25-Jan-2016 Electrical& Computer ENGINEERING Copyright 2006-2016, Philip Koopman, All Rights Reserved

More information

COSC345 Software Engineering. Basic Computer Architecture and The Stack

COSC345 Software Engineering. Basic Computer Architecture and The Stack COSC345 Software Engineering Basic Computer Architecture and The Stack Outline Architectural models A little about the 68HC11 Memory map Registers A little bit of assembly (never did us any harm) The program

More information

LCDs. Embedded Systems Interfacing. 20 September 2011

LCDs. Embedded Systems Interfacing. 20 September 2011 20 September 2011 How Polarizers Work How work How Color Work Other Technologies Reflective Nematic (no back light) Cholesteric Liquid Crystal Organic LED/Polymer LED Vacuum Florescent Display Display

More information

EE 308 Spring Exam 1 Feb. 27

EE 308 Spring Exam 1 Feb. 27 Exam 1 Feb. 27 You will be able to use all of the Motorola data manuals on the exam. No calculators will be allowed for the exam. Numbers Decimal to Hex (signed and unsigned) Hex to Decimal (signed and

More information

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture) COSC 243 Instruction Sets And Addressing Modes 1 Overview This Lecture Source Chapters 12 & 13 (10 th editition) Textbook uses x86 and ARM (we use 6502) Next 2 Lectures Assembly language programming 2

More information

C Language Programming

C Language Programming C Language Programming for the 8051 Overview C for microcontrollers Review of C basics Compilation flow for SiLabs IDE C extensions In-line assembly Interfacing with C Examples Arrays and Pointers I/O

More information

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3 Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3 o Comparison of C and Assembly programs for the HC12 o How to compile a C program using the GNU-C compiler o Using pointers to access

More information

Introduction to Microcontrollers II

Introduction to Microcontrollers II Introduction to Microcontrollers II brset, brclr Indexed Addressing Example µp Laboratory #2 BUFFALO Assembling Code EECE 143 Digital Design Project Purpose:To allow students to design their own digital

More information

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE The purpose of this lab is to introduce you to the layout and structure of Assembly Language programs and their format. You will write your own programs

More information

ELEG3923 Microprocessor Ch.9 Timer Programming

ELEG3923 Microprocessor Ch.9 Timer Programming Department of Electrical Engineering University of Arkansas ELEG3923 Microprocessor Ch.9 Timer Programming Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Programming 8051 Timers Counter programming Timer programming

More information

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

ECE331 Handout 3- ASM Instructions, Address Modes and Directives ECE331 Handout 3- ASM Instructions, Address Modes and Directives ASM Instructions Functional Instruction Groups Data Transfer/Manipulation Arithmetic Logic & Bit Operations Data Test Branch Function Call

More information

Cross Assembly and Program Development

Cross Assembly and Program Development Cross Assembly and ENGG4640/3640; Fall 2004; Prepared by Radu Muresan 1 Introduction Text Editor Program Ex. DOS, Notepad, Word saved as ASCII Source Code Assembler or Cross-Assembler Object Code Machine

More information

ECE 3120 Lab 1 Code Entry, Assembly, and Execution

ECE 3120 Lab 1 Code Entry, Assembly, and Execution ASSEMBLY PROGRAMMING WITH CODE WARRIOR The purpose of this lab is to introduce you to the layout and structure of assembly language programs and their format, as well as to the use of the Code Warrior

More information

POTENTIOMETER. Revision Class. Instructor / Professor LICENSE

POTENTIOMETER. Revision Class. Instructor / Professor LICENSE CME-11E9 EVBU LAB EXPERIMENT POTENTIOMETER Revision 03.11.13 Class Instructor / Professor LICENSE You may use, copy, modify and distribute this document freely as long as you include this license and the

More information

Introduction to the SX Microcontroller

Introduction to the SX Microcontroller CSUS EEE174 Lab Introduction to the SX Microcontroller 599 Menlo Drive, Suite 100 Rocklin, California 95765, USA Office/Tech Support: (916) 624-8333 Fax: (916) 624-8003 Author: Andrew Lindsay / Dennis

More information

Serial Communication Through an Asynchronous FIFO Buffer

Serial Communication Through an Asynchronous FIFO Buffer Serial Communication Through an Asynchronous FIFO Buffer Final Project Report December 9, 2000 E155 Nick Bodnaruk and Andrew Ingram Abstract: For our clinic, we need to be able to use serial communication

More information

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ). AS12 Assembler Directives A Summary of 9S12 instructions Disassembly of 9S12 op codes Huang Section 1.8, Chapter 2 MC9S12 V1.5 Core User Guide Version 1.2, Section 12 o A labels is a name assigned the

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications Q. 3.9 of HW3 EE 37 Microcontroller Applications (a) (c) (b) (d) Midterm Review: Miller Chapter -3 -The Stuff That Might Be On the Exam D67 (e) (g) (h) CEC23 (i) (f) (j) (k) (l) (m) EE37/CC/Lecture-Review

More information

LCD. Configuration and Programming

LCD. Configuration and Programming LCD Configuration and Programming Interfacing and Programming with Input/Output Device: LCD LCD (liquid crystal display) is specifically manufactured to be used with microcontrollers, which means that

More information

ME 6405 Introduction to Mechatronics

ME 6405 Introduction to Mechatronics ME 6405 Introduction to Mechatronics Fall 2005 Instructor: Professor Charles Ume LECTURE 9 Homework 1 Solution 1. Write an assembly language program to clear the usable internal RAM in the M68HC11E9. Solution:

More information

This simulated machine consists of four registers that will be represented in your software with four global variables.

This simulated machine consists of four registers that will be represented in your software with four global variables. CSCI 4717 Computer Architecture Project 1: Two-Stage Instuction Decoder Due: Monday, September 21, 26 at 11:59 PM What to submit: You will be submitting a text file containing two C functions, fetchnextinstruction()

More information

HC11 Instruction Set

HC11 Instruction Set HC11 Instruction Set Instruction classes 1. Accumulator and Memory 2. Stack and Index Register 3. Condition Code Register 4. Program control instructions CMPE12 Summer 2009 19-2 1 Accumulator and memory

More information

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4 Overview of the PIC 16F648A Processor: Part 1 EE 361L Lab 2.1 Last update: August 1, 2016 Abstract: This report is the first of a three part series that discusses the features of the PIC 16F648A processor,

More information

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families The Microcontroller Lecture Set 3 Architecture of the 8051 Microcontroller Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports. In most cases, all that is

More information

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text In this lecture the detailed architecture of 8051 controller, register bank,

More information

Application Note. Interfacing the CS5525/6/9 to the 68HC05. By Keith Coffey MOSI (PD3) SDO MISO (PD2) SCLK. Figure 1. 3-Wire and 4-Wire Interfaces

Application Note. Interfacing the CS5525/6/9 to the 68HC05. By Keith Coffey MOSI (PD3) SDO MISO (PD2) SCLK. Figure 1. 3-Wire and 4-Wire Interfaces Application Note Interfacing the CS5525/6/9 to the 68HC05 By Keith Coffey INTRODUCTION This application note details the interface of Crystal Semiconductor s CS5525/6/9 Analog-to-Digital Converter (ADC)

More information

CMPEN 472 Sample EXAM II

CMPEN 472 Sample EXAM II CMPEN 472 Sample EXAM II Name: Student ID number (last 4 digit): Please write your name on every page. Write your solutions clearly. You may use backside of each page for scratch but the solutions must

More information

TEMPERATURE SENSOR. Revision Class. Instructor / Professor LICENSE

TEMPERATURE SENSOR. Revision Class. Instructor / Professor LICENSE CME-11E9 EVBU LAB EXPERIMENT TEMPERATURE SENSOR Revision 04.02.11 Class Instructor / Professor LICENSE You may use, copy, modify and distribute this document freely as long as you include this license

More information

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers 8051 Peripherals On-Chip Memory Timers Serial Port Interrupts Computer Engineering 2 2-1 8051 Timers 8051 Timers The 8051 has 2 internal 16-bit timers named Timer 0 and Timer 1 Each timer is a 16-bit counter

More information

Texas Instruments Mixed Signal Processor Tutorial Abstract

Texas Instruments Mixed Signal Processor Tutorial Abstract Texas Instruments Mixed Signal Processor Tutorial Abstract This tutorial goes through the process of writing a program that uses buttons to manipulate LEDs. One LED will be hard connected to the output

More information

Interrupts, timers and counters

Interrupts, timers and counters Interrupts, timers and counters Posted on May 10, 2008, by Ibrahim KAMAL, in Micro-controllers, tagged Most microcontrollers come with a set of ADD-ONs called peripherals, to enhance the functioning of

More information

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application... Overview of the PIC 16F648A Processor: Part 1 EE 361L Lab 2.1 Last update: August 19, 2011 Abstract: This report is the first of a three part series that discusses the features of the PIC 16F684A processor,

More information

CSE 141L Computer Architecture Lab Fall Lecture 3

CSE 141L Computer Architecture Lab Fall Lecture 3 CSE 141L Computer Architecture Lab Fall 2005 Lecture 3 Pramod V. Argade November 1, 2005 Fall 2005 CSE 141L Course Schedule Lecture # Date Day Lecture Topic Lab Due 1 9/27 Tuesday No Class 2 10/4 Tuesday

More information

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory Table 1: Mnemonics s Dictionary ABA ABX ABY ADCA ADCB ADDA ADDB ADDD ANDA ANDB ASL ASLA ASLB ASLD ASR ASRA ASRB BCC BCLR BCS BEQ BGE BGT BHI BHS BITA BITB BLE BLO BLS BLT Add Accumulators Add B to X Add

More information

Microcontroller and Embedded Systems:

Microcontroller and Embedded Systems: Microcontroller and Embedded Systems: Branches: 1. Electronics & Telecommunication Engineering 2. Electrical & Electronics Engineering Semester: 6 th Semester / 7 th Semester 1. Explain the differences

More information

Lab 7: Asynchronous Serial I/O

Lab 7: Asynchronous Serial I/O CpE 390 Microprocessor Systems Lab 7: Asynchronous Serial I/O 1. Introduction Serial communications is the transfer of data, one bit at a time, over a communications channel. Serial communications can

More information

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003 ******************************************************* * This program for CSE472, Flash Memory Writing * * By Kyusun Choi, ID=0000 * * Date: 11/14/2009 * * Freescale CodeWarrior, for the MC9S12C32 Program

More information

Lab Experiment 9: LCD Display

Lab Experiment 9: LCD Display Lab Experiment 9: LCD Display 1 Introduction Liquid Crystal Displays (LCDs) provide an effective way for processors to communicate with the outside world. The LPC2148 board used in the lab is equipped

More information

BHARATHIDASAN ENGINEERING COLLEGE. III Year / V Semester / EEE MICROPROCESSORS AND MICROCONTROLLERS (R-2013)

BHARATHIDASAN ENGINEERING COLLEGE. III Year / V Semester / EEE MICROPROCESSORS AND MICROCONTROLLERS (R-2013) BHARATHIDASAN ENGINEERING COLLEGE III Year / V Semester / EEE MICROPROCESSORS AND MICROCONTROLLERS (R-2013) FREQUENTLY ASKED QUESTIONS IN UNIVERSITY EXAMINATION PART A UNIT 1-8085 PROCESSOR 1. Draw the

More information

Accurate Time and Interrupts

Accurate Time and Interrupts Accurate Time and Interrupts Matthew Beckler beck0778@umn.edu EE2361 Lab Section 007 March 7, 2006 Abstract In this lab, we create a very accurate digital clock using one of the microcontroller s timers.

More information

EE 308 Spring Hello, World!

EE 308 Spring Hello, World! Hello, World! Here is the standard hello, world program: #include main() { printf("hello, world\r\n"); To write the hello, world program, you need to use the printf() function. The printf() function

More information

Lecture test next week

Lecture test next week Lecture test next week Write a short program in Assembler doing. You will be given the print outs of all the assembler programs from the manual You can bring any notes you want Today: Announcements General

More information

Chapter 09. Programming in Assembly

Chapter 09. Programming in Assembly Chapter 09 Programming in Assembly Lesson 05 Programming Examples for Timers Programming TMOD Register 3 Write instructions to run T0 in Mode 0, external count inputs, internal start/stop control ANL TMOD,

More information

RCX Tutorial. Commands Sensor Watchers Stack Controllers My Commands

RCX Tutorial. Commands Sensor Watchers Stack Controllers My Commands RCX Tutorial Commands Sensor Watchers Stack Controllers My Commands The following is a list of commands available to you for programming the robot (See advanced below) On Turns motors (connected to ports

More information

Linking Assembly Subroutine with a C Program

Linking Assembly Subroutine with a C Program Linking Assembly Subroutine with a C Program To link an assembly subroutine to a C program, you have to understand how parameters are passed. For the CodeWarrior C compiler, one parameter is passed in

More information

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz G-CPU Important Notes (see Schwartz s lecture for a general overview) - The

More information

IAS0430 MICROPROCESSOR SYSTEMS

IAS0430 MICROPROCESSOR SYSTEMS IAS0430 MICROPROCESSOR SYSTEMS Fall 2018 Arduino and assembly language Martin Jaanus U02-308 martin.jaanus@ttu.ee 620 2110, 56 91 31 93 Learning environment : http://isc.ttu.ee Materials : http://isc.ttu.ee/martin

More information

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics This report is the first of a three part series that discusses the features of the PIC 16F94A processor. The reports will refer

More information

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes o Review of Addressing Modes o Which branch instruction to use (signed vs unsigned) o Using X and Y registers

More information

Lab 8: Debugging Embedded Devices and Software

Lab 8: Debugging Embedded Devices and Software Lab 8: Debugging Embedded Devices and Software Summary: Given pre-written code, isolate code and functional errors to create a working memory interfacing program. Learning Objectives: Debug and fix pre-written

More information

Embedded Systems. Introduction. The C Language. Introduction. Why C instead ASM. Introduction to C Embedded Programming language

Embedded Systems. Introduction. The C Language. Introduction. Why C instead ASM. Introduction to C Embedded Programming language Introduction Embedded Systems Introduction to C Embedded Programming language Why C instead ASM 1. C is a high level language, it is easier to write and read than assembly codes. 2. You don't have to think

More information