Download presentation
Presentation is loading. Please wait.
Published byDayna Ford Modified over 9 years ago
1
ECE 447: Lecture 2 Internal Input/Output Devices A/D Converter
2
ECE 447: Organization of MC68HC11 CPU RAM ROM EEPROM TIMER A/D SPI SCI PORT APORT BPORT CPORT DPORT E 8 8 (4) 8 2 4 6 8 332
3
ECE 447: I/O Device Architecture ….. Control registers instructions ….. Status registers status of the device Data registers ….. I/O device address1/name1 addressN/nameN..... inputs (operands) outputs (results)
4
ECE 447: Input/Output Register Types 1. Control registers - hold instructions that regulate the operation of internal I/O devices 2. Status registers - indicate the current status of internal I/O devices 3. Data registers - hold the input data sent to the I/O device and output data generated by this device 4. Data direction registers - control the direction (in or out) of the data flow to/from bidirectional data registers
5
ECE 447: I/O Addressing Schemes Memory mapped I/O (e.g., Motorola) 0 MAX I/O Control lines: read/write Separate I/O (e.g., Intel) 0 MAX I/O 0 max Control lines: read/write memory/io (Same Instructions)(Different Instructions)
6
ECE 447: Memory Map of MC68HC11E9 $0000 $1000 $B600 $FFFF $0000 $1000 $B600 $FFFF EXT $0000-$01FF 512 bytes RAM $1000-$103F 64 bytes I/O registers $B600-$B7FF 512 bytes EEPROM Single-chip modeExpanded bus mode $D000-$FFFF 12 Kbytes ROM $D000
7
ECE 447: Organization of MC68HC11 in Expanded Bus Mode CPU RAM ROM EEPROM TIMER A/D SPI SCI PORT A PORT DPORT E 8 (4) 2 4 6 8 3 32 EXTERNAL RAM EXTERNAL ROM EXTERNAL EPROM EXTERNAL I/O
8
ECE 447: New Micros Board Configuration 68HC11E9 68HC24 - Port Replacement Unit RAM 32 kB B C B C A DE RAM 512B EEPROM 512B ROM 12kB RAM 32 kB
9
ECE 447: Memory Map of MC68HC11E9 with External RAM $0000 $1000 $B600 $FFFF $0000-$01FF 512 bytes RAM $1000-$103F 64 bytes I/O registers $B600-$B7FF 512 bytes EEPROM Expanded bus mode $D000 $D000-$FFFF 12 kbytes ROM RAM
10
ECE 447: Recommended Memory Map Setting of MC68HC11E9 $0000 $1000 $2000 $B600 $6000 $FFFF $0000-$01FF 512 bytes RAM $1000-$103F 64 bytes I/O registers $B600-$B7FF 512 bytes EEPROM Expanded bus mode $D000 $2000-$5fff 16 kB Program RAM $D000-$FFFF 12 kbytes ROM $6000-$B5ff 21.5 kB Data RAM
11
ECE 447: A/D Converter V RH 6 V > 2.5 V V RL 0 V ADC 01010010 RL converts analog values in the range from V RL to V RH to digital values in the range from 0 to 255 (00 to FF in the hexadecimal notation) 00 FF
12
ECE 447: Communicating with A/D Control register instructions Control /Status register instructions/ status of the device Data registers A-to-D Converter outputs (results of conversions) 0x1039 OPTION 0x1030 ADCTL 0x1031 ADR1 0x1032 ADR2 0x1033 ADR3 0x1034 ADR4
13
ECE 447: A/D Operation Registers –OPTION0x1039 –ADCTL0x1030 –ADR1-40x1031-34 Four conversions done in one pass –Can either take four samples from one channel, or one sample from four channels 16 channels –8 for user operation PORTE0-7 –8 reserved for factory
14
ECE 447: Powering Up the A/D system Note: You really shouldn’t touch anything else in this register, therefore ensure you only change bit7!!
15
ECE 447: A/D Control & Status Register CCF:Conversion Complete Flag data is ready SCAN: Continuous Scan control 0 – only one set of conversions, 1 – Converts continually MULT: Multiple/Single Channel control 0 – One channel used with four conversions on it 1 – four channels used with one conversion per channel NOTE: Only 4 conversions total either way!!
16
ECE 447: A/D Results Registers When MULT = 0, CD-A refer to the channel that will have four conversions, which will all be stored in ADR1-4. When MULT = 1, CB,CA are ignored and CD,CC decide which set of four channels are used This means the channels are always grouped as: AN0-3 and AN4-7
17
ECE 447: Conversion Sequence 128 E Cycles:128*(0.5 s/cycle) = 64 s
18
ECE 447: Writing data to / Reading data from a particular memory location unsigned char * ADCTL_ptr = (unsigned char *) 0x1030; unsigned char result; *ADCTL_ptr = …; result = *ADCTL_ptr; Method 1 (first approximation)
19
ECE 447: Writing data to / Reading data from a particular memory location unsigned char * ADCTL_ptr = (volatile unsigned char *) 0x1030; unsigned char result; *ADCTL_ptr = …; result = *ADCTL_ptr; Method 1
20
ECE 447: Writing data to / Reading data from a particular memory location #define ADCTL (* (volatile unsigned char *) 0x1030); unsigned char result; ADCTL = …; result = ADCTL; Method 2
21
ECE 447: Writing data to / Reading data from a particular memory location #include “hc11e9.h” unsigned char result; ADCTL = …; result = ADCTL; Method 3 (not allowed in Experiment 1)
22
ECE 447: Setting and Clearing a bit Setting a bit #define BIT7 0x80 unsigned char c = …; c |= BIT3; Clearing a bit #define BIT7 0x80 unsigned char c = …; c &= ~BIT3;
23
ECE 447: Toggling a bit #define BIT7 0x80 unsigned char c = …; c ^= BIT3;
24
ECE 447: Testing a bit #define BIT7 0x80 unsigned char c = …; if (c & BIT7) ….. ; else ….. ;
25
ECE 447: Waiting for a bit to set #define CCF 0x80 #define ADCTL (* (volatile unsigned char *) 0x1030); while (!(ADCTL & CCF)) ; do nothing
26
ECE 447: Running program continuously while (1) { ……….. } Sequence of operations repeated continuously
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.