270 likes | 379 Views
m P Based Systems. Read Chapter 3 ( David E. Simon, An Embedded Software Primer ). Address Bus. Digital outputs (parallel port). Digital inputs (parallel input). Serial port. Data Bus. Analog input/output. m P based system. m P Based Systems. m P. LED. Memory System. I/O. Switch.
E N D
mP Based Systems Read Chapter 3 (David E. Simon, An Embedded Software Primer)
Address Bus Digital outputs (parallel port) Digital inputs (parallel input) Serial port Data Bus Analog input/output mP based system mP Based Systems mP LED Memory System I/O Switch Temperature Sensor Storage Embedded Systems Development Introduction Saâd Biaz
Memory and I/O mapping • Consider an 8-bit mP (imaginary) with a 6-bit address bus. First instruction to execute (after power on) is at address 48. • We have: • 16B ROM components (16 x 1B) • 16B RAM components (16 x 1B) • We plan to ¼ of the memory with ROM, ½ of the memory in RAM, and ¼ I/O Embedded Systems Development Introduction Saâd Biaz
000000 = 0 001111 = 15 I/O 010000 = 16 011111 = 31 RAM 1 26=64 010000 = 32 011111 = 47 RAM 2 110000 = 48 111111 = 63 ROM Memory and I/O mapping (2) • Let us map our address space • What is the address range for the ROM space? • What is the address range for the RAM space? • What is the address range for the I/O space A5A4A3A2A1A0 Embedded Systems Development Introduction Saâd Biaz
6 Address Bus A3 16B RAM 16B ROM mP A3 A0 A0 8 Data Bus D7 D7 D0 D0 Memory and I/O mapping (3) • 1) What is the size of the address space? • 2) What is the size of the address bus for the ROM and RAM components? Embedded Systems Development Introduction Saâd Biaz
CS CS CS R/W R/W R/W R/W RAM RAM ROM mP A5 A4 A3 A3 A3 A3 A0 A0 A0 A0 D7-D0 D7-D0 D7-D0 Address Bus D7-D0 8 Data Bus Memory Wiring A5A4 = 01 A5A4 = 10 A5A4 = 11 Embedded Systems Development Introduction Saâd Biaz
CS CS CS R/W R/W R/W R/W RAM RAM ROM VCC mP A5 A4 A3 A3 A3 A3 A0 A0 A0 A0 D7-D0 D7-D0 D7-D0 Address Bus D7-D0 8 Data Bus Input (switch) Wiring How to interface a switch? First, choose the address where to map the switch Second, build a circuit that connects the swich to data bus only when associated address is given by mP. Embedded Systems Development Introduction Saâd Biaz
CS CS CS R/W R/W R/W R/W RAM RAM ROM mP A5 A4 A3 A3 A3 A3 A0 A0 A0 A0 D7-D0 D7-D0 D7-D0 Address Bus D7-D0 8 Data Bus Input (switch) Wiring Let us choose the address 0 (bit D0) to map the switch A5A4A3A2A1A0 VCC D0 Embedded Systems Development Introduction Saâd Biaz
CS CS CS R/W R/W R/W R/W RAM RAM ROM mP A5 A4 A3 A3 A3 A3 A0 A0 A0 A0 D7-D0 D7-D0 D7-D0 Address Bus D7-D0 8 Data Bus Output (LED) Wiring Exercise I : Interface a LED at address 1, data bus line D4 A5A4A3A2A1A0 D4 Embedded Systems Development Introduction Saâd Biaz
CS R/W I/O: Device Controllers • The mP communicates with the device controller through registers accessible as if they are memory cells. • Example: a device controller with 2m registers Chip I/O Function Am-1 A0 D7-D0 Embedded Systems Development Introduction Saâd Biaz
CS Example of Device Controllers:Parallel I/O Port • Ports A, B, and C can be configured to be inputs or outputs. • Configuration is made by writing in the 8-bit control register • After configuration, ports A,B, or C can be read or written to as if they were memory cells. 8 Intel 8255 RD WD A 8-bit Control Reg. 8 B A1 C 8 A0 D7-D0 Embedded Systems Development Introduction Saâd Biaz
CS Example of Device Controllers:UART or Serial I/O Port • The 8-bit configuration register is used to select the speed (110bps to 19200bps), parity check, number of bits per word, lentgh of stop bits. • The mP writes to the data register the data to be sent serially on TX • The mP reads from the data register data received serially on RX. Intel 8251 RD WD TX 8-bit Data Reg. RX 8-bit Config. Reg. A0 D7-D0 Embedded Systems Development Introduction Saâd Biaz
CS Example of Device Controllers:Timer • The mP initializes a counter Ci with some value. • All counters are decremented at each tick of the clock input • When the counter Ci reaches 0, an impulse is output on the corresponding output Oi. Intel 8253 RD WD O0 16-bit Counter 0 O1 16-bit Counter 1 CLK O2 16-bit Counter 2 A1 A0 D7-D0 8-bit Config. Reg. Embedded Systems Development Introduction Saâd Biaz
Direct Memory Access (DMA) • The idea is to transfer directly I/O stream to/from memory without using the CPU (long bus cycles) • Reminder, to transfer a word from I/O to memory. The mP must: • Fetch its “reading” instruction (IN AX,DX) • Decode the instruction, execute it • Fetch the “write” instruction • Decode the instruction, execute it • Test if done (involves loops/jumps..etc) Embedded Systems Development Introduction Saâd Biaz
Direct Memory Access (DMA) (2) • Transfering CONTIGUOUS data can be made more efficiently: • A counter is needed to generate increasing addresses and proper control signals to the memory. Embedded Systems Development Introduction Saâd Biaz
BusAck BusReq DMAAck DMAReq Direct Memory Access (DMA) RAM mP Address/Control Bus Data Bus I/O DMA Controller Embedded Systems Development Introduction Saâd Biaz
Gluing a mP-based system • Decoding functions may require some components (especially if address bus very large 32 to 64 bits). • PALs • FGPAs Embedded Systems Development Introduction Saâd Biaz
Built-Ins on Microcontrollers • Address decoding • Timers • I/O • DMA • ADC-DAC (Analog-Digital Converter … ) Embedded Systems Development Introduction Saâd Biaz
mP Based Systems(Example: Microcontroller Rabbit 2000) Read Chapter 1 and 2 (Rabbit Semiconductor, Rabbit 2000 Microprocessor User’s Manual) http://www.rabbitsemiconductor.com/docs/
Rabbit 2000 Characteristics • 8-bit data bus • 20-bit address bus (extensible) • Software driven system clock • 2 timers • 40 bit parallel configurable I/O • 4 serial ports • 1 watchdog timer Embedded Systems Development Introduction Saâd Biaz
Rabbit 2000 Characteristics (2) Embedded Systems Development Introduction Saâd Biaz
Rabbit 2000 System Clock Embedded Systems Development Introduction Saâd Biaz
Saving Power (By Software) • Add memory wait states • Turn off clock doubler (if in use) • Divide frequency by 8 (select f/8) • Run code in RAM, not in flash • Use for the CPU and peripheral clock the 32K oscillator (disable main oscillator) Embedded Systems Development Introduction Saâd Biaz
Timers • RTC: 48-bit register driven by 32K • Watchdog timer (0.25s, 0.5s, 1s, or 2s) Embedded Systems Development Introduction Saâd Biaz
Timers (2) Embedded Systems Development Introduction Saâd Biaz
Serial Communication Embedded Systems Development Introduction Saâd Biaz