Unformatted text preview:

ECE 3620 Introduction to Microcomputers 2016 Macam S Dattathreya PhD Wayne State University Electrical and Computer Engineering 1 Course Topics Unit Topic Duration weeks 1 Microcomputer Execution of Assembly Programs A Brief Overview Instructions Addressing Modes Data Representation Arithmetic and Logic Branching and Simple Assembly Programs 68HC11 Assembly Programming and Development Tools Stacks Subroutines and Data Structures The Hardware Configuration and Interrupts Parallel I O Ports B and C The Analog to Digital Converter Port E The Timing System and Port A 2 3 4 5 6 7 8 1 2 2 2 1 1 1 2 2016 Macam Introduction to Microcomputers 2 Unit 8 The Timing System and Port A 2016 Macam Introduction to Microcomputers 3 Table of Contents Timing System The Free Running Counter Real Time Interrupts Port A Simple Mode of Operation Input Capture Function Output Compare Function The Pulse Accumulator 2016 Macam Introduction to Microcomputers 4 68HC11 Timing Requirement Delay creation and measurement Period measurement Event counting Time of day tracking Periodic interrupt generation Remind processor to perform other tasks Waveform generation 2016 Macam Introduction to Microcomputers 5 Timing System of 68HC11 Timers generate waveforms Varying frequencies Five output timers Counters count certain events on the input lines E g rising edges of signal 2016 Macam Introduction to Microcomputers 6 Timing System of 68HC11 Controlled by a crystal oscillator E Clock of crystal frequency 8 MHz clock EVBPlus2 E clock 2 MHz Each instruction cycle time 0 5 s Timing controls rate of instruction execution and most of Input output Port A Timer counter hardware implementation 2016 Macam Introduction to Microcomputers 7 Timing System of 68HC11 EXTAL XTAL CPU Core Timer counter system Port A 68HC11 Crystal Oscillator Creates an electrical signal with precise frequency 2016 Macam Introduction to Microcomputers 8 Timing System of 68HC11 Timers generate waveforms Varying frequencies Five output timers Independent configuration settings Programmable to take actions on output pins E g Do nothing set output to high low or invert the output values 2016 Macam Introduction to Microcomputers 9 Timer System of 68HC11 16 bit free running main timer counter Performs many functions Real time interrupt RTI Three input capture functions Five output compare functions 8 bit pulse accumulator More discussions to follow 2016 Macam Introduction to Microcomputers 10 Timing System of 68HC11 2016 Macam Introduction to Microcomputers 11 The Free Running Counter Cleared at RESET After this is Read only E clock 2 MHz Time resolution 0 5 s Control Registers their memory locations Timer Counter TCNT Register 16 Bit Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 8 TCNTH 100E Bit 0 TCNTL 100F Incremented every tick of the E clock cannot written by the program Note Always read TCNT as a 16 bit number using LDD LDX or LDY 100E instruction Reading 8 bit portions separately gives erroneous results When Higher bytes are read the counter freezes the lower byte of the register This assures the results are always read in two bytes and are correct 216 65 536 counts to cycle it around once i e 2 MHz 65536 0 5 s 32 768 ms 2016 Macam Introduction to Microcomputers 12 The Free Running Counter Note The returned count value on a double byte read corresponds to the value of the free running counter at the second to last cycle of the double byte read instruction Example Assume TCNT 01FB before executing the following program segments Segment 1 LDD 100E Segment 2 LDAA 100E LDAB 100F what will be in ACCA and ACCB after these instructions 2016 Macam Introduction to Microcomputers 13 The Free Running Counter Before Program Segment 1 Timer Counter TCNT Register 2 Bytes TCNTL TCNTH 100E 100F FB 01 Execute the instruction LDD 100E Requires 5 cycles to read Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 01 02 FC FD FE FF 00 TCNTL 100F TCNTH 100E D Register 01FF This means if you use this ACCA 01 and ACCB FF Note The TCNT is incremented by 1 after E cycle 5 i e after LDD instruction Read High byte into D register Low byte is frozen Note The TCNT still reflects the exact number of E clock ticks so TCNT has 0200 after LDD 2016 Macam Introduction to Microcomputers 14 The Free Running Counter Solution First Segment Recall The lower byte of the TCNT register is frozen when higher byte is being read in a 16 bit read of the TCNT register In extended mode LDD requires 5 cycles Loads the high byte in the 4th cycle At the 4th cycle TCNT 01FF This value is frozen and read into D register So ACCA gets 01 and ACCB gets FF Note The TCNT still reflects the exact number of E clock ticks so TCNT has 0200 after LDD 2016 Macam Introduction to Microcomputers 15 The Free Running Counter Before Program Segment 2 Timer Counter TCNT Register 2 Bytes TCNTL TCNTH 100E 100F FB 01 ACCA 01 ACCB 03 Execute the instruction LDAA 100E Requires 4 cycles to read Cycle 3 Cycle 5 Cycle 7 Cycle 1 Cycle 2 Cycle 4 Cycle 8 Cycle 6 01 02 FC FD FE FF 00 01 02 03 TCNTL 100F TCNTH 100E Read High byte into ACCA next Read Low byte into ACCB tick happens the next instruction LDAB 100F happens These results are not correct TCNT register can keep track of time also used to implement time delays But implementing time delays using TCNT might not be simple example next 2016 Macam Introduction to Microcomputers 16 The Free Running Counter Solution Second Segment LDAA requires 4 cycles Reads 100E during the fourth cycle But TCNT increments with every cycle so TCNT will be 01FF when read and ACCA 01 Next LDAB reads 100F four cycles later when TCNT 0203 and ACCB gets 03 The result of the read is 0103 Not close to the correct result 2016 Macam Introduction to Microcomputers 17 The Free Running Counter Example An increment of 10000 decimal in the TCNT register corresponds to 0 5 s 10000 5 ms This subroutine utilizes the free running timer in to implement a 5 ms delay 2016 Macam Introduction to Microcomputers 18 The Free Running Counter Reads TCNT register values to D register Adds 5 ms to D register Reads TCNT register Continuously until it is larger than register D What is wrong with this program 2016 Macam Introduction to Microcomputers 19 The Free Running Counter Problem 1 TCNT could go negative value by adding 10000 delay so BGT signed comparison miss functions Resolution Use BHI instruction unsigned comparison Problem 2 16 bit addition limitation Overflow may occur for other


View Full Document

WSU ECE 3620 - The Timing System and Port A

Download The Timing System and Port A
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The Timing System and Port A and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Timing System and Port A and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?