MC68HC11 Laboratory ManualN. NatarajanDepartment of Electrical and Computer EngineeringUniversity of Michigan-Dearborn4901 Evergreen RoadDearborn-4812
10 CHAPTER 1. INTRODUCTION TO HC111.2.4 Writing and entering your first program: Using MMLet us write a short program that will add three numbers store
100 CHAPTER 9. ANALOG TO DIGITAL CONVERSION;STEP 2; INITIATE CONVERSION;LDAA #%00100011 *SCAN=1, MULT=0, PIN = 011 (PE3)STAA ADCTL;MAIN LOOPLOOP;STEP
9.7. A SIMPLE DIGITAL VOLTMETER 101JSR OUTLHLFLDAA #’.JSR OUTAPULA *GET THE SAVED VALUEJSR OUTRHLFJSR OUTCRLF; BACK FOR MORE UNLESS USER TYPES AN ESCA
1.2. TASKS 11call C100Note you can abbreviate any command by entering enough characters to identifyit. Since no other command starts with the letter c
12 CHAPTER 1. INTRODUCTION TO HC11>ASM C200C200 STX $FFFF>LDAA D000B6 D0 00C203 STX $FFFF>ADDA D001BB D0 01C206 STX $FFFF>ADDA D002BB D0 0
1.2. TASKS 13(b) Find out the ascii codes for the letters in the phrase THIS CLASS ISFUN. To get you started, here are some codes: code for ’T’ is 54,
14 CHAPTER 1. INTRODUCTION TO HC11LOAD TIn Hyperterm, use the ASCII file transfer command (use the Transfer menu itemto get to it) to transfer the PROG
Chapter 2Introduction to Looping2.1 ObjectiveTo become familiar with elementary loops and simple input/outputs functions.2.2 Simple Input/OutputOne of
16 CHAPTER 2. INTRODUCTION TO LOOPING2.2.1 The function OUTAThe function OUTA will transmit whatever is in register A over the serial com-munication l
2.3. BRANCHING 17Exercise:1. Using the MM command (memory modify) enter the following values inmemory locations D000, D001, · · ·: 30 31 32 33 41 42 4
18 CHAPTER 2. INTRODUCTION TO LOOPINGExercise:1. Using the HC11 reference book, identify 5 instructions that do not affectthe C flag, but affects some ot
2.4. LOOPING 19Exercises:1. Assemble the following code in your PC, transfer the S19 file to HC11, runthe program and write down the output of the prog
2
20 CHAPTER 2. INTRODUCTION TO LOOPINGSWIVerify that CALL C100 and CALL C200 produces the same output. Explainwhy this is so, and how and why the loop
2.4. LOOPING 21ORG $D000FCB $55, $6F, $66, $4D, $2D, $44, $62, $72, $6ERun the above program using CALL C3004. Modify the above program as shownbelow
22 CHAPTER 2. INTRODUCTION TO LOOPINGLDAA 0,XADDA $10,XSTAA $20,XINXDECBBRA CALLOOHCALLAYSWIORG $D000FCB $55, $6F, $66, $4D, $44, $62, $72, $6EFCB $41
2.5. OTHER CONDITIONAL BRANCHES 23DECBBRA KINGSCABBAGESLDAA #$0AJSR OUTAJSR OUTASWI2.5 Other Conditional Branches2.5.1 Signed and unsigned numbersSo f
24 CHAPTER 2. INTRODUCTION TO LOOPINGcompared are of opposite sign) and one for unsigned comparison where no specialcases need be considered.2.5.2 com
2.5. OTHER CONDITIONAL BRANCHES 25Branch to LOCif A >= MEMCMPA MEMBGE LOC *Branch if Greater or EqualBranch to LOCif A < MEMCMPA MEMBLT LOC *Bra
26 CHAPTER 2. INTRODUCTION TO LOOPING; IT USES CODE REUSE IN THIS SIMPLE FORM. TO ADD 54, IT; IT ADDS 6 AND THEN FALLS DOWN TO THE CASE OF ADDING 48.;
2.5. OTHER CONDITIONAL BRANCHES 27ADD54ADDA #6ADD48ADDA #6ADD42ADDA #6ADD36ADDA #6ADD30ADDA #6ADD24ADDA #6ADD18ADDA #6ADD12ADDA #6ADD6ADDA #6DONESTAA
28 CHAPTER 2. INTRODUCTION TO LOOPING>MM D000D000 23 29>C C00029 41P-C04B Y-AAAA X-D002 A-20 B-AA C-D9 S-004A>Using LoopsHere is a version us
2.5. OTHER CONDITIONAL BRANCHES 29DONESTAA $D001LDX #$D000JSR OUT1BSP *SAME AS OUT1BYT EXCEPT PRINTS A SPACE AFTER THE NUMBERJSR OUT1BYTSWI;;;;;;;;;;;
Contents1 Introduction to HC11 71.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.2 Tasks . . . . . . . . . . . . . . . .
30 CHAPTER 2. INTRODUCTION TO LOOPING
Chapter 3Functions and bit manipulations3.1 ObjectiveTo become familiar with bit level operations and writing functions. This lab alsoillustrates the
32 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONSmost often used sentinels are zero (also known as ASCII-Z string), 26 (also knownas CONTROL-Z string, or
3.4. WRITING YOUR FIRST FUNCTION 33next and then the program section, though it is easier to follow the code if theprogram section precedes the data s
34 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONSthe registers the way they were before the functions used them1.Here are the basic rules for writing func
3.4. WRITING YOUR FIRST FUNCTION 35You use FCB to initialize consecutive memory loication (when you transfer thecode from the PC). The label associate
36 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONSADCA #20STAA SEED ;don’t forget to save it backRTS;;;;;;;;;;;;;;;;;;;;;;;;End: RAND ;;;;;;;;;;;;;;;;;;;;;
3.5. YOUR SECOND FUNCTION 37code for 0 or the code for 1 depending on whether the carry is cleared or set5.Note the function involves a counting loop.
38 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONS; the function destroys the value in a,; so re load it! then print second digitTBAJSR OUTRHLF; now print
3.5. YOUR SECOND FUNCTION 39; restore the registersPULXPULBPULARTS;;;;;;;;;;;;;;;;;;;;;;;End: PRBINARY;;;;;;;;;;;;;;;;;;;;3.5.1 Test your functionWe c
4 CONTENTS3.4 Writing your first function . . . . . . . . . . . . . . . . . . . . . . 323.4.1 On random sequences . . . . . . . . . . . . . . . . . . .
40 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONSJSR RANDJSR PRBINARYSWI;;; INSERT YOUR CODE FOR PRBINARY HERE;;; INSERT YOUR CODE FOR RAND HEREORG $D000;
3.7. CLEARING BITS 41SETBIT4PSHALDAA $00ORAA #%00010000STAA $00PULARTS;; INSERT THE CODE FOR FUNCTIONS RAND AND PRBINARY HEREORG $D000;; ALL THE DATA
42 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONSJSR CLRBIT4LDAA $00JSR PRBINARY *PRINT AFTER CLEARSWI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3.8. TOGGLING BITS 43ORG $C100JSR OUTCRLF *NEED THIS FOR OUTPUTS TO LINE UP!JSR RANDSTAA $00JSR PRBINARY *PRINT BEFOREJSR TGLBIT4LDAA $00JSR PRBINARY
44 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONSORG $D000;; ALL THE DATA ITEMS GO HERE.$;;;;;;;;;;;;;;;;;;;;;;;end of code ;;;;;;;;;;;;;;;;;;;;;;;;3.9 Te
3.10. HARDWARE INTERFACING 45NOSTR FCC /NO/FCB 4;;;;;;;;;;;;;;;;;;;;;;;end of code ;;;;;;;;;;;;;;;;;;;;;;;;3.10 Hardware InterfacingWorking with rando
46 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONSdrive devices from these pins (as long as you do not supply more than 5 mA). PA7is bidirectional and you,
3.10. HARDWARE INTERFACING 4733.3KLEDTo groundTo test pointPA5 for exampleFigure 3.1: Test Probe. Make sure that the resistor is connected to the anod
48 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONS2. Connect the input circuit as shown in figure 3.2.3.10.2 Controlling the LEDUse memory modify, MM $1000,
Chapter 4Programs4.1 ObjectiveTo b ecome familiar with writing programs. This lab also illustrates the use ofassembler directives.4.2 What you should
CONTENTS 57.5 Variable frequency generator . . . . . . . . . . . . . . . . . . . . . 807.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . .
50 CHAPTER 4. PROGRAMS5. Compiler keeps track of the life and scope of the variable so that the variableis available only when it is in the scope of t
4.4. YOUR FIRST PROGRAM 513. If the instruction is a RMB instruction, then add the value after the mnemonicto the location counter.4. If the instructi
52 CHAPTER 4. PROGRAMSpseudo language, I will use a C like syntax1. The program we want to write shouldbe similar to the following C program (since HC
4.5. ON YOUR OWN! 53;v4 = 044;ldaa #@44staa v4;total = v1+v2+v3+v4;ldaa v1adda v2adda v3adda v4staa total;print total as 2 digit hex numberldaa totalj
54 CHAPTER 4. PROGRAMSchar v;char total;main() {v = 0;total = 0;v = v+1;total = total + v;v = v+1;total = total + v;v = v+1;total = total + v;v = v+1;
4.5. ON YOUR OWN! 55anda #$0F; in C, use: getchar() & 0X0FUse the above sequence to let the user specify the count. When expectingthe user to ente
56 CHAPTER 4. PROGRAMS(f) Modify the program so that the output reads some thing like:v1 = 07v2 = 1Cv3 = 23v4 = 467. Write a function that will be pas
4.5. ON YOUR OWN! 57goto foo;bar:return 0;}10. Type the following C program, run it to see what the output is. Rewrite theprogram in assembly language
58 CHAPTER 4. PROGRAMSif (c == ’1’) goto one;if (c == ’2’) goto two;fprintf(stderr,"\n\nNot a valid choice!\n");goto foo;one:fprintf(stderr,
Chapter 5Tables5.1 ObjectiveTo become familiar with table driven code.5.2 What you should doYou will have to turn in your LST files for the programs yo
6 CONTENTS
60 CHAPTER 5. TABLESORG $3000 *data section...primes fcb 2,3,5, 7, 11, 13, 17, 19, 23, 29 *table of some primesnprimes equ 10 *number of entries in
5.5. WORKING WITH TABLES 61a Yes/No value. A convenient way to return a Yes/No value is to use a hardwareflag. Let us use the Carry flag. The function w
62 CHAPTER 5. TABLESinit equ $ffa9input equ $ffacoutput equ $ffafoutlhlf equ $ffb2outrhlf equ $ffb5outa equ $ffb8out1byt equ $ffbbout1bsp equ $ffbeout
5.5. WORKING WITH TABLES 63org $2100ldx #preamblejsr outstrgmainloopjsr incharldx #vowelsldab #nvowelsjsr lookupbcs isvowelldx #nostrjsr outstrgobra m
64 CHAPTER 5. TABLESExercise: Type the above program, assemble it, transfer the S19 file to the68HC11, and run the program with CALL 2100. When the pro
5.5. WORKING WITH TABLES 65that we accept only digits and ignore non-digits (the user may be in the habit oftyping spaces, dashes etc. You want to sil
66 CHAPTER 5. TABLESfcc /Hit the reset button to quit/fcb 10fcc /=====================================/fcb 10,10,10, 4; setup the table of digitsdigit
5.5. WORKING WITH TABLES 67;;; Add the code for lookup function hereExercise: Type the above program and run it. Enter the following input andexplain
68 CHAPTER 5. TABLEShexchars fcc /0123456789AaBbCcDdEeFf/hextrans fcb 0,1,2,3,4fcb 5,6,7,8,9fcb 10,10, 11,11, 12,12, 13,13, 14,14, 15,15nhexchars equ
5.5. WORKING WITH TABLES 69out2bsp equ $ffc1outcrlf equ $ffc4outstrg equ $ffc7outstrgo equ $ffcainchar equ $ffcdvecinit equ $ffd0org $3000; setup some
Chapter 1Introduction to HC111.1 ObjectiveTo become familiar with HC11 and using BUFFALO utilities, interacting usingthe terminal program, transferrin
70 CHAPTER 5. TABLES; print 2 spaces so the output looks neatldaa #’ ’jsr outajsr outapula ; get it backjsr outajsr outcrlfbra mainloop;;;;;;;;;;;;;;;
5.5. WORKING WITH TABLES 71lkplooptstbbeq notthere *this is the basic counting loopcmpa 0,xbeq founditinxdecbbra lkploopnotthereclcrtsfounditsecrtsExe
72 CHAPTER 5. TABLESL 5U 8M 6
Chapter 6Timing using Polling6.1 ObjectiveIntroduces polling timer overflow flag to create a simple clock and to generateON-OFF output signals.6.2 Getti
74 CHAPTER 6. TIMING USING POLLINGWe can use this to create a30.522Hz square wave by toggling an output pin everytime counter rolls over. Here is the
6.3. TIMING 756.3.1 Slowing it downIn the last exp eriment, we toggle the pin so fast that chances are you did notnotice the LED’s blink. We can slow
76 CHAPTER 6. TIMING USING POLLING;NOW TOGGLE PA4LDAA #%00010000EORA PORTASTAA PORTA;DO IT ALL OVER AGAINBRA LOOP1
Chapter 7Interrupt Processing7.1 ObjectiveTo become familiar with interrupt processing.7.2 BackgroundIn an earlier lab, you had to generate a 30.52 Hz
78 CHAPTER 7. INTERRUPT PROCESSING; CLEAR THE FLAG. NO HARM IS DONE IF IT IS ALREADY CLEAREDLDAA #%10000000STAA TFLAG2;WAIT FOR THE FLAG TO BE SETLOOP
7.3. INTERRUPTS 79(b) However, if the mask is set, then request for service is generated.i. The I bit in the CCR is a master disable switch. If this i
8 CHAPTER 1. INTRODUCTION TO HC11CTRL-A Quit.BF <addr1> <addr2> [<data>] Block fill.BR [-][<addr>] Set up breakpoint table...
80 CHAPTER 7. INTERRUPT PROCESSING2. Write the service routine. As part of the service make sure you turn off theflag that generated the interrupt.3. Le
7.4. THE REAL TIME INTERRUPT 81; INTERRUPT SERVICESERVICE; TOGGLE PA4LDAA #%00010000EORA PORTASTAA PORTA; TURN OFF THE FLAG!LDAA #%10000000STAA TFLG2;
82 CHAPTER 7. INTERRUPT PROCESSINGLast two bits of PACTL Time between interrupts00 4.096 ms (244.1 Hz)01 8.192 ms (122 Hz)10 16.384 ms (61 Hz)11 32.76
7.4. THE REAL TIME INTERRUPT 83;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INTERRUPT SERVICESERVICE; TOGGLE PA4LDAA #%00010000EORA PORTASTAA PORTA; TURN OFF
84 CHAPTER 7. INTERRUPT PROCESSING7.5 The output compare interruptThe HC11 has 5 OCx interrupts. These are like alarm clocks. You set a desired’alarm’
7.5. THE OUTPUT COMPARE INTERRUPT 85SERVICE; TOGGLE PA4LDAA #%00010000EORA PORTASTAA PORTA; TURN OFF THE FLAG!LDAA #%01000000 <= This is differentS
86 CHAPTER 7. INTERRUPT PROCESSING;set the next interrupt to occur 2000 clock ticks after thisLDD TOC2 <= This is differentADDD #2000STD TOC2 <=
Chapter 8Signal Generation8.1 ObjectiveTo become familiar with generating square waves.8.2 BackgroundIn an earlier lab, you had to generate a square w
88 CHAPTER 8. SIGNAL GENERATION8.3 Variable frequency signal generatorIn this experiment, we will generate a square wave with frequency selected by th
8.4. 500 HZ TONE GENERATOR 89SEILDD #1000STD ONTIMELDD #3000STD OFFTIMELDAA #%01000000STAA TMSK1CLI; Now go about your business of printing Z’sLDAA #’
1.2. TASKS 9modify the memory, the command will first echo the value already in memory. Ifyou don’t want to change it, press the space bar, command wil
90 CHAPTER 8. SIGNAL GENERATIONRESTADDD TOC2STD TOC2 ; BUMP ALARM SETTING; TURN OFF THE FLAG!LDAA #%01000000STAA TFLG1RTI; Connect the service to the
8.5. VARIABLE FREQUENCY GENERATOR 91FDB 851, 804, 759, 716, 676OFFTIMETBLFDB 3409, 3217, 3037, 2866, 2706FDB 2554, 2410, 2275, 2147, 2027Note that it
92 CHAPTER 8. SIGNAL GENERATIONBefore AfterLDAA #’Z’ LOOPLOOP JSR OUTA JSR INPUTBRA LOOP TSTABEQ LOOPANDA #$0FTAB ; B HAS INDEXLDX #ONTIMETBLABXABXLDY
Chapter 9Analog to Digital Conversion9.1 ObjectiveTo become familiar with Analog to Digital Conversion.9.2 BackgroundIn this lab you will learn how to
94 CHAPTER 9. ANALOG TO DIGITAL CONVERSIONwhereD The converted digital valueV Measured voltageV RL Lower limit voltageV RH Upper limit voltageb· · ·c
9.5. PROCESS OF TAKING A MEASUREMENT 95pins PE0-PE3 or the pins PE4-PE7. If you chose the first the group of pins thenthe voltage in PE0 will be conver
96 CHAPTER 9. ANALOG TO DIGITAL CONVERSIONthis to 1 if you want scanning; or else, set it to zero. Bit #4 is the MULT bit. Setthis to 1 if you want mu
9.7. A SIMPLE DIGITAL VOLTMETER 97scanning mode, there is no need to issue any new commands. Measure theinput voltage, V and compute255V5. Also note d
98 CHAPTER 9. ANALOG TO DIGITAL CONVERSION4. Take a reading (this is easy!)LDAA ADR15. Convert it to decivolts by multiplying by 50 and then dividing
9.7. A SIMPLE DIGITAL VOLTMETER 99TAB *COPY A TO BH2B.LTCMPB #10 *IS B < 10BLO H2B.DONE *IF SO WE ARE DONESUBB #10 *B <- B-10ADDA #6 *A <- A+
Commentaires sur ces manuels