Professional Documents
Culture Documents
A microcontroller is a small, low-cost computer-on-a-chip which usually includes: An 8 or 16 bit microprocessor (CPU). A small amount of RAM. Programmable ROM and/or flash memory. Parallel and/or serial I/O. Timers and signal generators. Analog to Digital (A/D) and/or Digital to Analog (D/A) conversion. Often used to run dedicated code that controls one or more tasks in the operation of a device or a system.
Also called embedded controllers, because the microcontroller and support circuits are often built into, or embedded in, the devices they control. Devices that utilize microcontrollers include car engines, consumer electronics (VCRs, microwaves, cameras, pagers, cell phones .. ), computer peripherals (keyboards, printers, modems.. ), test/measurement equipment (signal generators, multimeters, oscilloscopes ). Microcontrollers usually must have low-power requirements (~. 05 - 1 W as opposed to ~10 - 50 W for general purpose desktop CPUs) since many devices they control are battery-operated.
EECC250 - Shaaban
#1 Lec # 20 Winter99 2-9-2000
Microcontroller Components
From sensors To actuators Displays, keyboard etc.
Single Chip
Examples: Motorolas 68HC11, 68HC12, AMD 29K, Zilogs Z8, Z80, Intels 8052, Microchips PIC Low-power, embedded versions of desktop CPUs: e.g Intels 80486
EECC250 - Shaaban
#2 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#3 Lec # 20 Winter99 2-9-2000
32-Kbyte Flash EEPROM with 2-Kbyte Erase-Protected Boot Block. 768-Byte EEPROM. 1-Kbyte RAM with Single-Cycle Access for Aligned or Misaligned Read/Write. 8-Channel, 8-Bit Analog-to-Digital (A/D) Converter. 8-Channel Timer. 16-Bit Pulse Accumulator:
External Event Counting, Gated Time Accumulation.
EECC250 - Shaaban
#4 Lec # 20 Winter99 2-9-2000
MC68HC912B32
EECC250 - Shaaban
#5 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#6 Lec # 20 Winter99 2-9-2000
0x08FF 0x0900
EECC250 - Shaaban
#7 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#8 Lec # 20 Winter99 2-9-2000
68HC12 Registers
A B D X Y SP PC CCR 8-bit Accumulator A 8-bit Accumulator B 16-bit Double accumulator D (A : B) 16-bit Index register X 16-bit Index register Y 16-bit Stack pointer 16-bit Program Counter Condition code register:
S X H I N Z V C STOP instruction control bit Non-maskable interrupt control bit Half-carry status bit Maskable interrupt control bit Negative status bit Zero status bit Twos complement overflow status bit Carry/Borrow status bit
EECC250 - Shaaban
#9 Lec # 20 Winter99 2-9-2000
5-bit and 9-bit signed integers are used only as offsets for indexed addressing modes. 16-bit effective addresses are formed during addressing mode computations. 32-bit integer dividends are used by extended division instructions. Extended multiply and extended multiply-and-accumulate instructions produce 32-bit products.
EECC250 - Shaaban
#10 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#11 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#12 Lec # 20 Winter99 2-9-2000
LDAA $F03B ; load register A with 8-bit value from address $F03B
LDX $0900 ; load index register X with 16-bit value in $0900, $0901
EECC250 - Shaaban
#13 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#14 Lec # 20 Winter99 2-9-2000
Post-decrement and postincrement versions of the addressing mode use the initial value in the index register to access the memory location affected by the instruction, then change the value of the index register. LDX 2,SP+ LDAA 1,SP+ ;equivalent to PULX ;equivalent to PULA
EECC250 - Shaaban
#15 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#16 Lec # 20 Winter99 2-9-2000
Example:
LDAA [10,X]
In this example, X holds the base address of a table of pointers. Assume that X has an initial value of $1000, and that the value $2000 is stored at addresses $100A and $100B. The instruction first adds the value 10 to the value in X to form the address $100A. Next, an address pointer ($2000) is fetched from memory at $100A. Then, the byte value stored in location $2000 is read and loaded into the A accumulator.
EECC250 - Shaaban
#17 Lec # 20 Winter99 2-9-2000
Example:
JMP GO1 DC.W GO2 DC.W GO3 DC.W [D,PC] PLACE1 PLACE2 PLACE3
Assume that the value in D is $0002. The JMP instruction adds the values in D and PC to form the address of GO2. Next the CPU reads the address PLACE2 from memory at GO2 and jumps to PLACE2.
EECC250 - Shaaban
#18 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#19 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#20 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#21 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#22 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#23 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#24 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#25 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#26 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#27 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#28 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#29 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#30 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#31 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#32 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#33 Lec # 20 Winter99 2-9-2000
The numeric range of short branch offset values is $80 (128) to $7F (127)
EECC250 - Shaaban
#34 Lec # 20 Winter99 2-9-2000
The numeric range of short branch offset values is $80 (128) to $7F (127)
EECC250 - Shaaban
#35 Lec # 20 Winter99 2-9-2000
The numeric range of long branch offset values is $8000 (32,768) to $7FFF (32,767)
EECC250 - Shaaban
#36 Lec # 20 Winter99 2-9-2000
The numeric range of long branch offset values is $8000 (32,768) to $7FFF (32,767)
EECC250 - Shaaban
#37 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#38 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#39 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#40 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#41 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#42 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#43 Lec # 20 Winter99 2-9-2000
Main
;load stacktop ;load first byte in A ;add second value to A result in A ;store result in answer ;done with program
EECC250 - Shaaban
#44 Lec # 20 Winter99 2-9-2000
loop:
ITER COUNT
EECC250 - Shaaban
#45 Lec # 20 Winter99 2-9-2000
EECC250 - Shaaban
#46 Lec # 20 Winter99 2-9-2000