EE 308
Lecture Outline for Spring 2001
Wednesday 1/16
- Introduction to Microprocessors and Microcontrollers.
- Pack and Barrett, Chapter 1
- Figures
- Course Overview
- Cruise Control Block Diagrams and Flowchart
- Block Diagrams of Simple Microprocessor and Microcontroller
- Harvard architecture and Princeton (Von Neuman) architecure microprocessor
block diagrams
- Memory map for a Princeton architecture microprocessor
Friday 1/18
- Introduction to the HC12 Microcontroller
- Pack and Barrett, Sections 2.1 and 2.2
- CPU 12 Reference Manual, Sections 2.1-2.2
- Figures
- 68HC12 Address Space
- 68HC12 ALU
- 68HC12 Programming Model
- Some HC12 Instructions Needed for Lab
1
- A Simple Assembly Language Program
- Assembling an Assembly Language Program
Monday 1/21
- Decimal, Hexadecimal and Binary Numbers
- Pack and Barrett, Appendix C
- Figures
- Binary numbers are a code, and represent what the programmer intends for
the code
- Convert binary and hex numbers to unsigned decimal
- Convert unsigned decimal to hex
- Unsigned number line and wheel
- Signed number line and wheel
- Binary, Hex, Signed and Unsigned Decimal
- Signed number representation --- 2's Complement form
- Using the 1's complement table to find 2's complements of hex numbers
- Overflow and Carry
- Addition and subtraction of binary and hexadecimal numbers
- The Condition Code Register (CCR): N, Z, V and C bits
Wednesday 1/23
- Addition and Subtraction of Hexadecimal Numbers
- Pack and Barrett, Appendix C
- Simple assembly language programming
- Pack and Barrett, Sections 2.1 --- 2.3
- HC12 Addressing Modes
- Pack and Barrett, Section 2.5
- Figures
- The N, Z, C and V bits of the Condition Code Register (CCR)
- Addition and Subtraction of Hex numbers
- Simple HC12 programs
- Hex code generated from a simple HC12 program
- Things you need to know for HC12 assembly language programming
- HC12 Addressing Modes
- Inherent, Extended, Direct, Immediate, Indexed, and Relative Modes
- Summary of HC12 Addressing Modes
Friday 1/25
- More on addressing modes and HC12 instructions.
- Pack and Barrett, Chapter 2
- Figures
- Using X and Y registers as pointers
- How to tell which branch instruction to use
- How to hand assemble a program
- Number of cycles and time taken to execute an HC12 program
Monday 1/28
- Assembler Directives of the Cosmic Assembler
- A Summary of HC12 Instructions
- Pack and Barrett, Sections 2.4, 2.6, 2.7
- CPU 12 Reference Manual, Chapter 5
- Figures
- Cosmic Assembler Directives
- A labels is a name assigned the address of the location counter where ithe
label is defined
- Use of {\tt dc} and {\tt ds} directives
- A summary of HC12 instruction
- How to tell which branch instruction to use
Wednesday 1/30
- Disassembly of HC12 op codes
- Writing an assembly language program
- Pack and Barrett, Sections 2.7, 3.2
- Figures
- Disassembly of HC12 op codes
- Use flow charts to lay out structure of program
- Use common flow structures
- if-then
- if-then-else
- do-while
- while
- Do not use spaghetti code
- Plan structure of data in memory
- Plan overall structure of program
- Work down to more detailed program structure
- Implement structure with instructions
- Optimize program to make use of instruction efficiencies
- Do not sacrifice clarity for efficiency
Friday 2/1
- Another simple program in assembly language
- Using the stack and the stack pointer
- Pack and Barrett, Section 3.3
- Figures
- A program to add all the odd numbers in a memory array
- Flow charts
- Assembly language program
- Assembly listing file
- Assembly map file
- The Stack and the Stack Pointer
- The stack is an area of memory used for temporary storage
- The stack pointer points to the last byte pushed onto the stack
- Some instructions which use the stack, and how data is pushed onto and
pulled off of the stack.
Monday 2/4
- More on programming in assembly language
- Introduction to Ports on the HC12
- Pack and Barrett, Section 3.3
- Figures
- Good programming style
- Tips for writing programs
- Input and Output Ports
- Simplified Input Port
- Simplified Output Port
- Ports on the HC12
- PORTA, PORTB, DDRA, DDRB
- A simple program to use PORTA and PORTB
- Subroutines and the Stack
- An example of a simple subroutine
- Using a subroutine with PORTA to make a binary counter on LEDs
Wednesday 2/6
- Some more simple assembly language programs
- Using HC12 input and output ports
- Pack and Barrett, Section 3.3
- Figures
- Using a subroutine to wait for and respond to an event
- Using an input port to chech the state of DIP switches
- Using an output port to control LEDs
- An assembly language program to display a pattern on a set of LEDs
Friday 2/8
- Introduction to Programming the HC12 in C
- Figures
- Comparison of C and Assembly programs for the HC12
- How to compile a C program using the Cosmic compiler
- Using pointers to access the contents of specific addresses in C
- Using the hc12b32.h header file
Monday 2/11
- More on Programming the HC12 in C
- Figures
- Some C basics
- Setting and clearing bits in Assembly and C
- Some simple programs in C
- Program to sum the odd numbers in an array
- Program to count the number of negative numbers in an array
- Function to delay for a given number of milliseconds
- Program to increment the LEDs connected to PORTA
- Program to display a particular pattern on PORTA
Wednesday 2/13
Friday 2/15
Monday 2/18
- Introduction to the HC12 Hardware Subsystems
- Pack and Barrett, Sections 5.2, 7.1-7.6.2
- M68HC12B Family Manual, Sections 12.3-12.4
- Figures
- A summary of HC12 hardware subsystems
- Introduction to the HC12 Timer subsystem
- The HC12 has a 16-bit free-running counter to determine the time and event
happens, and to make an event happen at a particular time
- The counter is normally clocked with an 8 MHz clock
- The Timer Overflow (TOF) bit -- when the timer rolls over from
0x0000 to 0xFFFF it sets a flip-flop to show that this has
happened.
- The Timer Prescaler (PR2:0) bits of Timer Interrupt Mask 2
(TMSK2) register: Allows you to change the frequency of the clock
driving the 16-bit counter.
- Setting and clearing bits in Assembly and C
Wednesday 2/20
- Resets on the HC12
- Introduction to Interrupts on the HC12
- Pack and Barrett, Chapter 6
- M68HC12B Family Manual, Section 4
- Figures
- What happens when you reset the HC12?
- Using the Timer Overflow Flag to implement a delay on the HC12
- Introduction to Interrupts
- How to generate an interrupt when the timer overflows
- How to tell the HC12 where the Interrupt Service Routine is located
- Using interrupts on the HC12
- The HC12 registers and stack when a TOF interrupt is received
- The HC12 registers and stack just after a TOF interrupt is received
- Interrupt vectors for the 68HC912B32
Friday 2/22
- The Real Time Interrupt
- Pack and Barrett, Section 6.8
- M68HC12B Family Manual, Sections 10.7-10.8
- Figures
- Exceptions on the HC12
- Using interrupts on the HC12
- The Real Time Interrupt on the HC12
Monday 2/25
- The HC12 Input Capture Function
- Pack and Barrett, Section 7.8.1, 7.8.2
- M68HC12B Family Manual, Section 12.4
- Figures
- Interrupts on the HC12
- Capturing the time of an external event
- The HC12 Input Capture Function
- Registers used to enable the Input Capture Function
- Using the HC12 Input Capture Function
- A program to use the HC12 Input Capture in polling mode
- Using the Keyword volatile in C
- Using D-Bug12 Routines to Print Information to the Terminal
- A program to use the HC12 Input Capture in interrupt mode
Wednesday 2/27
- The HC12 Output Compare Function
- Pack and Barrett, Section 7.8.3, 7.8.4
- M68HC12B Family Manual, Section 12.4
- Figures
- Making an event happen at a specific time on the HC12
- The HC12 Output Compare Function
- Registers used to enable the Output Compare Function
- Using the HC12 Output Compare Function
- A program to use the HC12 Output Compare to generate a square wave
- Introduction of Pulse Width Modulation
Friday 3/1
- The HC12 Pulse Width Modulation System
- M68HC12B Family Manual, Section 11
- Figures
- What is Pulse Width Modulation
- The HC12 Pulse Width Modulation system
- Registers used by the PWM system
- How to set the period for PWM Channel 0
- How to set the clock for PWM Channel 0
- Interdependence of clocks for Channels 0 and 1
- PWM Channels 2 and 3
- Using the HC12 PWM
- A program to use the HC12 PWM
Monday 3/4
- More on the HC12 Pulse Width Modulation System
- M68HC12B Family Manual, Section 11
- Figures (Same as for Friday, 3/1)
Wednesday 3/6
- Analog-to-Digital Converters
- Pack and Barrett, Sections 9.1-9.4
- Figures
Friday 3/8
- The HC12 A/D converter
- Pack and Barrett, Sections 9.5-9.6
- M68HC12B Family Manual, Section 17
- Figures
Monday 3/18
- Introduction the Serial Communications
- Pack and Barrett, Sections 10.1-10.3
- M68HC12B Family Manual, Section 14.2
- Figures
Wednesday 3/20
- The HC12 Serial Peripheral Inteface (SPI)
- Pack and Barrett, Section 10.5
- M68HC12B Family Manual, Section 14.4
- Figures
Friday 3/22
Monday 3/25
Wednesday 3/27
Monday 4/1
- The HC12 in Expanded Mode
- Pack and Barrett, Chapter 8
- M68HC12B Family Manual, Section 5
- Figures
Wednesday 4/3
- The HC12 in Expanded Mode
- Pack and Barrett, Chapter 8
- M68HC12B Family Manual, Section 5
- Figures
Friday 4/5
- The HC12 in Expanded Mode - Timing
- Pack and Barrett, Chapter 8
- M68HC12B Family Manual, Section 5
- Figures
Monday 4/8
- The HC12 in Expanded Mode - External Ports
- Pack and Barrett, Chapter 8
- M68HC12B Family Manual, Section 5
- Figures
Wednesday 4/10
- The HC12 in Expanded Mode - External Ports
- Pack and Barrett, Chapter 8
- M68HC12B Family Manual, Section 5
- Figures
Friday 4/12
- The HC12 in Expanded Mode - External Ports
- Pack and Barrett, Chapter 8
- M68HC12B Family Manual, Section 5
- Figures
Monday 4/15
- Preparation for Final Lab Project
- Simple Motor Control
- Figures
Monday 4/15
- More Preparation for Final Lab Project
Friday 4/19
- The HC12 Pulse Accumulator
- M68HC12B Family Manual, Sections 12.4.11-12.4.13
- Pack and Barrett, Section 7.6.4
- Asychronous Serial Communications
- The HC12 Serial Communications Interface
- M68HC12B Family Manual, Section 14.3
- Pack and Barrett, Sections 10.2-10.4
- Figures
Monday 4/22
Wednesday 4/24
Friday 4/26
Monday 4/29
Wednesday 5/1
Friday 5/3
Tuesday 5/7
Note: The lecture figures are presented in Adobe Acrobat format. You need to
open them using the Adobe Acrobat Reader program. This is a free program
available from Adobe:
Bill Rison,
<rison@ee.nmt.edu >