Computer Science Microcontroller Embedded systems today Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-2
Minuteman missile 1962 Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-3 Apollo guidance computer 1968 (lunar mission) Concept by MIT Hardware by Raytheon Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-4
Definition An embedded system is a special-purpose system in which the computer is encapsulated by or dedicated to the device or system it controls. A microcontroller is a computer-on-a-chip designed for self-sufficiency and cost-effectiveness, in contrast to a general-purpose microprocessor used in PCs. Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-5 Microcontroller Single integrated circuit, key features: central processing unit input/output interfaces such as serial ports peripherals such as timers and watchdog circuits RAM for data storage ROM for program storage (Harvard architecture) clock generator - often an oscillator for a quartz timing crystal, resonator or RC circuit Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-6
Time to market Shortest possible development time by easy to use development tools enough on-chip-resources efficient for high level languages Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-7 MCU vs. CPU stand alone cheap dedicated application high performance universal application PC environment small package Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-8
Development tools Selecting the right development tools evaluation kit (e.g. AVR Butterfly) architectural simulator (e.g. AVR Studio) on chip debugger (e.g. AVR JTAGICE mk-ii) C compiler (e.g. WinAVR) Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-9 Programming language Assembly vs. C same productivity in lines of code but 1 line of C code will do much more C source code is more structured easier to debug assembly code is smaller preferarable for small programs up to 4kB assembly code is always faster write time critical (parts) in assembly 1/8 μs (125 ns) per cycle (at 8 MHz), most operations need only 1 cycle Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-10
'C' Advantages over Assembly www2.tech.purdue.edu\ecet\courses\referencematerial\atmel\index.html: * Programming and program test time is drastically reduced * Knowledge of the processor instruction set is not required. Only rudimentary knowledge of the memory structure of the CPU is desirable, although not necessary. * Details like register allocation, the addressing of the various memory, and data types are managed by the compiler. * Programs get a formal structure and can be divided into separate functions. This provides better program structure. * The ability to combine variable selections with specific operations improves program readability. * Keywords and operational functions can be used that closely resemble the human thought process. * The supplied and supported C libraries contain many standard routines such as formatted output, numeric conversions, and floating point arithmetic. * Existing program parts can be more easily included into new programs by the use of the modular programming techniques. * The C language is a very portable language (standardized to ANSI X3J11), enjoys wide support, and is easily obtained for most systems. This means that any existing program investment can be quickly adapted to other microcontrollers. ATmega16 features overview (1) RISC Architecture (Reduced Instruction Set Computing) 131 instructions (operation codes) 32 x 8 bit general purpose registers Memory 16 kb flash memory 1 kb RAM 0,5 kb EEPROM (Electrically-Erasable Programmable Read-Only Memory) Periphal features 2 timer/counters, 8-bit 1 timer/counter, 16-bit 8 channel, 10 bit ADC (Analog-to-Digital-Converter) 1 serial interface, programmable Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-12
ATmega16 features overview (2) I/O 32 programmable I/O lines Speed 1 16 MHz clock rate Packages 40 pin PDIP 44-lead TQFP, 44-quadQFN/MLF Voltage, power 4.5-5.5 V 1.1 ma Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-13 ATmega architecture Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-14
ATmega16 architecture Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-15 ATmega16 CPU program memory (opcode) address of next opcode current opcode switch control lines depending on opcode read/write memory (variables) non volatile values (e.g.sensor calibration) Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-16
Port What is a Port? A gate from the CPU to external hardware components The CPU communicates with these components, reads from them or writes to them 64 different ports, not all of them physically available in all AVR types (see the data sheets for the processor type) Fixed address, over which the CPU communicates. The address is independent from the type of AVR. (e.g. the port adress of port B is always 0x18. Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-17 Register Registers are special storages with 8 bits capacity and they look like this: Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 The special character of registers, compared to other storage sites, is that they can be used directly in assembler and C commands, operations with their content require only a single command word, they are connected directly to the CPU (with the accumulator) they are source and target for calculations. Ports are registers too. Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-18
ATmega16 pinouts Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-19 ATtiny11 pinouts Prof. Dr. Siepmann Fachhochschule Aachen - Aachen University of Applied Sciences 24. März 2009-20