Sunteți pe pagina 1din 37

INTRODUCTION TO EMBEDDED SYSTEMS

A PRACTICAL APPROACH USING ATMEL


MICROCONTROLLERS

Dr. Hossam Eldin Mostafa

2017

WWW.ATMEL.COM
Outline
1- Motivation and Inspiration

2- Embedded Systems Overview

3- Parts of an Embedded System

4- Embedded Systems Processors

5- ATMEL Microcontrollers

7- Practicing with Atmel AVR Microcontrollers

6- Practicing with Atmel 8051 Based Microcontrollers.


1- Motivation and Inspiration
Why Would I Attend This Seminar?
What Should I Gain from Learning
Embedded Systems?
- Self Satisfaction (you are not alone).

- Learn how systems work and become aware of the new technologies.

- Design impressive course projects and successful graduation projects -

- Add something practical to your CV to get better job opportunity in


the field in your country or abroad.

- Convert your ideas into working prototypes so that you will be able to
present them to investors.

- Make your own product and start your own business.


If you hear, you forget
If a man can write a better
If you see, you remember
book, preach a better sermon,
If you do, you understand
or make a better mousetrap,
than his neighbor, though he
build his house in the woods,
the world will make a beaten
path to his door.
INSPIRE
(Great)
Benefit

DEMONSTRATE
(Superior)

EXPLAIN
(Good)
TELL
(Average)

Effort - Information
Some Inspiration
Silicon Valley, San Jose, California
ADOBE ORACLE AMD EBAY

GOOGLE INTEL YAHOO APPLE

HP
HP: Success Story
- Hewlett Packard (HP) is the world's largest information Technology
Company. Its foundation is called the Birthplace of Silicon Valley.

- On a quiet, tree-lined residential street near Stanford University, the HP


Garage stands today as the symbol of innovation and the entrepreneur-
ial spirit.

- College friends Bill Hewlett and Dave Packard pursued the dream of a
company of their own. They were graduated from Dept. of Electrical
Engineering, Stanford University in 1935.

- The two men blazed a trail at the forefront of the electronics revolution.
They started HP in a Garage in Palo Alto California in 1939.

- They started with HP200A, a precision audio oscillator, which was pur-
chased in large quantities by The Walt Disney Company.

http://www.hp.com/go/garage/
Bill and Dave: 1950 (left) - 1989 (right) HP Garage: 1939 (left) - 2005 (right)

Bill and Dave with Dr. Frederick Terman,


the Stanford University Professor who
encouraged his students to start up their
electronics companies, instead of joining
established firms (1970).

HP Garage Sign
Procter & Gamble (PG)
P&G was founded in 1837 by two men who met by chance. William
Procter, emigrating from England, who was a candle maker, and James
Gamble, arriving from Ireland, who was a soap maker.
http://www.pg.com/en_US/downloads/media/Fact_Sheets_CompanyHistory.pdf

MathWorks
MATLAB was created in the late 1970s by Cleve Moler, prof. of computer
science department at the University of New Mexico. He designed it to
give his students access to Matrix Operation without the need to learn
Fortran. Jack Little, an engineer, was exposed to it during a visit Moler
made to Stanford University in 1983. Recognizing its commercial poten-
tial, he joined with Moler and rewrote MATLAB in C and founded The
MathWorks in 1984 to continue its development.
http://www.mathworks.com/company/aboutus/founders/
Microsoft

Bill Gates, the world's wealthiest person from 1995 to 2017


($80,000,000,000)

Why did he leave The study at Harvard (oldest university


in the USA) without getting an academic degree in 1975?

Why did he establish Microsoft in 1975?

The reason is:


Building a microprocessor kit !!!!!!!!!!!!!
Wait for the whole story at the end of this seminar
2- Embedded Systems Overview

• Computing systems are everywhere

• Most of us think of “desktop” computers


PC’s - Laptop- Mainframes - Servers

• But there’s another type of computing system


Far more common...
• Embedded computing systems

- Computing systems embedded within electronic devices.

- Hard to define. Nearly any computing system other


than a desktop computer.

- Billions of units produced yearly, versus millions of


desktop units.

- Perhaps 50 per household and per automobile.

Processors are here and here and even here


Embedded Systems Examples
• List of Embedded Systems
Anti lock brakes Modems
Auto focus cameras MPEG Decoders
Automatic teller machines Network Cards
automatic toll systems Network Switches/Rout-
avionic systems ers
battery chargers ON-board Navigation
camcoders Pagers
cell phones Photocopiers
cellphone stations Point of sale systems
cordless phones Portable video games
digital cameras Printers
electronic card readers Satellite phones
electronic toys Scanners
Factory control systems Microwave ovens and
Fingerprint identifiers dish washers
Home security systems speech recognizes
Medical instruments stereo systems
Video game consoles Teleconferencing systems
Washers and dryers Television
VCY - DVD Players Temperature Controllers
And the list goes on . . . . .
3- Parts of an Embedded System

USER EMBEDDED SYSTEM

I/O

MEMORY PROCESSOR

HARDWIRED UNIT
• Application-specific logic
• Timers
• A/D and D/A conversion

ENVIRONMENT
8
- Actuators
mechanical components (e.g., valve)
Controlled by Analog to Digital Converters

- Sensors
input data (e.g., accelerometer for airbag control)
Converted by Digital to Analog Converters

- Processing
Data conversion, storage, Decision-making
Parts of a Digital Camera

Digital camera chip


CCD

CCDpreprocessor Pixel coprocessor D2A


A2D

lens

JPEGcodec Microcontroller Multiplier/Accum

DMAcontroller Display ctrl

Memorycontroller ISAbus interface UART LCDctrl


4- Embedded Systems Processors

Embedded Processors Microprocessor

Microcontroller

FPGA/CPLD

DSP

ASIC
Microprocessors
Tens of Companies, Tens of Types
Intel - Motorola - AMD - Zilog . . . . .

Microcontrollers
Tens of Companies, Hundreds of Types
Intel - Atmel - Microchip - Motorola - Cypress . . . . .

FPGA/CPLD (Field Programmable Gate Arrays/ Complex Programmable


Logic Devices)
Few Companies, Tens of Types
Xilinx - Altera - Actel.

DSP (Digital Signal Processors)


Few Companies - Tens of types
Texas Instruments - Analog Devices - Motorola.

ASIC (Application Specific Integrated Circuit)


Tens of Companies, Hundreds of Types
5- ATMEL Microcontrollers
Why ATMEL?
- Best Flash Memory in the World.
- Very Cheap
- Very Secure
- Contains Hardware Multiplier
- Very Fast, one MIPS per MHz
- Provides 8, 16, and 32 bit microcontrollers.
- Variety in packages (from 6 pins to 128 pins)
- Reliable (Schneider chose Atmel AVR ATMEGA128 to
be the main and only processor of their family of PLCs)
- Rich in peripherals (Ports - Timers - Counters - ADC -
DAC - PWM - UART - USB - CAN - I2C - SPI - Ethernet)
Check the newest ATmega128RFA1 AVR with built in
2.4GHz Wireless Zigbee Transceiver.
A. 8051 Based Microcontrollers

Classical AT89CXXXX Family


Ex: AT89C4051 & AT89C52

In System Programmable AT89SXXXX Family


Ex: AT89S4051 & AT89S52

Single Cycle AT89LPXXXX Family


Ex: AT89LP6440 & AT89LP214 & AT89LP4052
B. AVR Based Microcontrollers

Classical AT90S Family


AT90S8515 & AT90S8535

Powerful ATMEGA Family


ATMEGA8515 & ATMEGA16 & ATMEGA8 &
ATMEGA128

Small ATTINY Family


ATTINY2313 & ATTINY15
USB AT90USB Family
AT90USB162 & AT90USB82 & AT90USB1287

Super ATXMEGA Family


ATXMEGA16 & ATXMEGA32 & ATXMEGA128

AVR32 Family
AT32UC3A0128 & AT32UC3A0256
C. ARM Based Microcontrollers

ARM7 AT91SAM7 Family


AT91SAM7S128 & AT91SAM7S512 & AT91SAM7X128

ARM9 AT91SAM9 Family


AT91SAM9260 & AT91SAM9263

CORTEX SAM3U Family


SAM3U1C & SAM3U2C & SAM3S4C
Internal Structure of A Microcontroller
Input Output Ports

Flash Program Timers


Memory
Interrupts

Serial Port

CPU PWM
SRAM Data
Memory
USB Device

USB Host

EEPROM Ethernet Controller


Memory
ADC / DAC

I2C SPI
Example: ATMEL AT89S52 Microcontroller 40 DIP package

Physical Chip Physical Pinout Logical Pinout


Requirements for Working with Microcontrollers
Specific (depends on the General (does not depend on
used microcontroller) the selected microcontroller)

A. Software Requirements
1- Assembler or C Compiler
2- Downloading Software

B. Hardware Requirements
1- Microcontroller Chip
2- Programmer
3- Development Board
4- PC
5- Power Supply
6- Serial or USB Module
7- Quartz Crystal
8 - I/O Interfaces
6. Practicing with Atmel AVR Microcontrollers
6.A.1 Software Requirements: Assembler

AVRSTUDIO free Assembler from ATMEL


http://www.atmel.com/dyn/products/tools_card_v2.asp?tool_id=2725

6.A.1 Software Requirements: C Compiler

CodeVision (recommended) : http://www.hpinfotech.ro/


Or
IAR C Compiler: www.iar.com

(You may download limited visions from the internet)


Advice
You should learn C language very well in order to be professional in
Embedded Systems
A flasher Code Using Assembly and C Languages for ATTINY2313
Assembly(flasher.asm) C (flasher.c)
;THIS PROGRAM IS USED TO TEST ATTINY2313 //THIS PROGRAM IS USED TO TEST ATTINY2313
; LED IS CONNECTED TO PORT PORTB.0 ;THROUGH 100 //LED IS CONNECTED TO PORT PORTB.0
;OHM THE LED WILL FLASH ;EVERY ONE SECOND //THROUGH 100 OHM THE LED WILL FLASH EVERY
//ONE SECOND
.device at90s2313 ; Device is AT90S2313
.include "TN313def.inc" include <tiny2313.h>
#define LED PORTB.0
.def temp = r16 void delay();
.def dly= r17
.def delcnt= r18 ; Loop Counter void main(void)
DELAY: clr delcnt ;Init Loop Counter {
loop1: dec delcnt PORTB = 0x00;
nop DDRB = 0xFF;
brne loop1
dec dly while (1)
brne loop1 {
ret LED = 1;
delay();
RESET: ldi temp, LOW(RAMEND) LED = 0;
out SPL, temp ; Initialize SPL delay();
sertemp }
out DDRB ,temp ; PORTB = all outputs }
out PORTB, temp
loop: cbi PORTB, PB0 void delay()
{
ldi dly, $FF ; Initialize delay of about 65 ms unsigned int x,y;
rcall DELAY ; Number of cycles = 1026 * del + 4 for(x = 0; x<1000; x++)
sbi PORTB, PB0 for(y = 0; y<100; y++);
ldi dly, $FF ; Initialize delay of about 65 ms }
rcall DELAY ; Number of cycles = 1026 * del + 4
rjmp loop ; Repeat forever
After assembling flasher.asm , or compiling flasher.c, the machine
language file flasher.hex is produced as shown.

Flasher.hex (from flasher.asm) Flasher.hex (from flasher.c)


:020000020000FC :0E00000013C0FECFFDCFFCCFFBCFFACFF9CF60
:1000000011C0189518951895189518951895189564 :10000E00F8CFF7CFF6CFF5CFF4CFF3CFF2CFF1CFC6
:1000100018951895189522272A950000E9F71A9542 :10001E00F0CFEFCFEECFEDCF0000F894EE27ECBB94
:10002000D9F708950FED0DBF0FEF07BB08BBC098C0 :10002E00E5BFF8E1A4B7A77FA4BFF1BDE1BD8DE0A8
:0C0030001FEFF1DFC09A1FEFEEDFF9CFE9 :10003E00A2E0ED938A95E9F780E8A0E6ED938A9524
:00000001FF :10004E00E9F7E6E2F0E085919591009761F0A591D0
:10005E00B59105901590BF01F00105900D92019795
:10006E00E1F7FB01F0CFE0E0E3BBE0E0E4BBE0E072
:10007E00E5BBEFEDEDBFC0E8D0E000C0E0E0E8BBCF
:10008E00EFEFE7BBC09A04D0C09802D0FBCFFFCFF2
:10009E0015D000E010E0083EE3E01E0760F420E01B
:1000AE0030E02436E0E03E0718F42F5F3F4FF9CFE3
:1000BE000F5F1F4FF0CF07D0249608953A932A93DF
:1000CE001A930A9308953B812A8119810881089514
:00000001FF

This file must be downloaded into the flash memory of the ATTINY2313
microcontroller using the download software and the programmer.
6.A.2 Software Requirements: Download Software

We have three methods depending on the hardware of the used pro-


grammer.

a- If you have MEGAPRG Parallel Port Programmer

Use the ChipBlaster software from inside CodeVision C Compiler. This


supports a large category of AVR Microcontrollers.

http://www.hpinfotech.ro/

Or using the software that comes with MEGAPRG.


MEGAPRG Parallel Programmer Supported Devices

Classical AVRs : AT90S2313 - AT90S2323 - AT90S2343 - AT90S4433 - AT90S8515 - AT90S8535 - ATmega169


ATmega103 - ATmega161 - ATmega163 - ATmega323 - ATmega48 - ATmega8 - ATmega88 - ATmega16 -
ATmega165 - ATmega168 - ATmega168P - ATmega32 - ATmega128 .
ATMEGA AVRs : ATmega1284P - ATmega48PA - ATmega8A ATmega88PA ATmega8515 ATmega16A
ATmega162 - ATmega165P ATmega168PA - ATmega328P - ATmega32A - ATmega324P - ATmega324PA -
ATmega644PA - ATmega325 - ATmega325P - ATmega3250 - ATmega3250P - ATmega644 - ATmega64 -
ATmega645 - ATmega6450 - ATmega640 - ATmega128A - ATmega1280 - ATmega2561 - ATmega2560
ATtiny AVRs : ATtiny13 - ATtiny2313 - ATtiny24 - ATtiny25 - ATtiny26 - ATtiny44 - ATtiny45 - ATtiny48 -
ATtiny84 - ATtiny85.
CAN AVRs :AT90CAN128 - AT90CAN32 - AT90CAN64
LCD AVRs :ATmega3290P - ATmega329P - ATmega169P - ATmega329 - ATmega3290 - ATmega649
USB AVRs : AT90USB1286 - AT90USB1287 - AT90USB162 - AT90USB646 - AT90USB647 - AT90USB82 -
ATmega16U2- ATmega16U4 - ATmega32U2 - ATmega32U4 - ATmega8U2
RF AVRs : AT86RF401

MEGAPRG supports 5v and 3.3v AVR devices


b- If you have AVRUSBPRG USB Programmer
Use ATMEL’s free software AVRSTUDIO 4. It is downloadable from:

http://www.atmel.com/dyn/products/tools_card_v2.asp?tool_id=2725

This programming software programs all types of AVR microcon-


trollers and it is upgradable for new devices.

c- If you have USBMOD or UARTMOD Modules

You can use the Self Downloader Software which programs


ATMEGA16, ATMEGA32,ATMEGA162, ATMEGA64, ATMEGA64
microcontrollers with built in Loader software.

Contact HYPERES (www.hyperes.com) for more details.

Here you can program the controller and obtain serial communication
for debug and test.
AVRUSBPRG Supported AVRs
Classical AVRs : AT90S1200 - AT90S2313 - AT90S2323 - AT90S2343 - AT90S4433 - AT90S8515 - AT90S8535 -
ATmega169 ATmega103 - ATmega161 - ATmega163 - ATmega323 - ATmega48 - ATmega48P - ATmega8 -
ATmega88 - ATmega88P ATmega16 - ATmega165 - ATmega168 - ATmega168P - ATmega32 - ATmega128 -
ATtiny11 - ATtiny13 - ATtiny15 - ATtiny26 - ATtiny44
ATMEGA AVRs : ATmega1284P - ATmega48PA - ATmega8A ATmega88PA ATmega8515 ATmega16A
ATmega162 - ATmega165P ATmega168PA - ATmega328P - ATmega32A - ATmega324P - ATmega324PA -
ATmega644PA - ATmega325 - ATmega325P - ATmega3250 - ATmega3250P - ATmega644 - ATmega64 -
ATmega645 - ATmega6450 - ATmega640 - ATmega128A - ATmega1280 - ATmega2561 - ATmega2560
ATtiny AVRs : ATtiny12 - ATtiny13A - ATtiny2313 - ATtiny24 - ATtiny24A - ATtiny25 - ATtiny261 - ATtiny43U -
ATtiny44A - ATtiny45 - ATtiny461 -ATtiny48 - ATtiny84 - ATtiny85 - ATtiny861 - ATtiny88
CAN AVRs :AT90CAN128 - AT90CAN32 - AT90CAN64 - ATmega16M1 - ATmega32C1 - ATmega32M1 -
ATmega64M1
Lighting AVRs : AT90PWM1 - AT90PWM2 - AT90PWM2B - AT90PWM2B - AT90PWM3 - AT90PWM3B -
AT90PWM3B
LCD AVRs :ATmega3290P - ATmega329P - ATmega169P - ATmega329 - ATmega3290 - ATmega649 - ATmega6490
USB AVRs : AT90USB1286 - AT90USB1287 - AT90USB162 - AT90USB646 - AT90USB647 - AT90USB82 -
ATmega16U2- ATmega16U4 - ATmega32U2 - ATmega32U4 - ATmega8U2
Battery Management AVR: ATmega16HVA - ATmega16HVB - ATmega32HVB
RF AVRs : AT86RF401

AVRUSBPRG supports also all the different voltages and speed grades versions of the listed devices.

d- If you have AVRJTAGPRG

You can program AVR types with JTAG Interface such as


ATMEGA16, ATMEGA32, ATMEGA128.
Note: This programmer currently is not available from HYPERES,
it will be available in the near future.
Answer

January 1975 issue of Popular Electronics

Search GOOGLE for


BILL GATES OPEN LETTER TO HOBBYISTS
INTERVIEW WITH BILL GATES
Upcoming Lectures

- Printed Circuit Boards Design and Fabrication

- Introduction to FPGAs and CPLDs


THANK YOU

S-ar putea să vă placă și