Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture1, Included Universal AVR kit full design (Schematic and PCB). By: WALID BALID1.
ﺍﻟﺘﺠﺎﺭﺏ ﺍﻟﻌﻤﻠﻴﺔ
Programming
Embedded Systems Microcontroller
You Can Practice Microcontroller Programming Easily Now!
Tuesday, December 15, 2009
2.
General Introduction about this course
Assembly
AVR
Bascom-AVRBasic
Proteus
Development Board
50
2
3. Practical Class 1 Programming Microcontrollers
Bascom-AVR Compiler Bascom-AVR
Bascom-AVR
·
_ ·
Faculty of Electrical and Electronic Eng. 3 Automatic Control & Automation Dept.
4.
Compile ·
·
Bascom-AVR
LCD Designer
Graphic Converter
*.bgfGLCD
4
5. Practical Class 1 Programming Microcontrollers
Plugin Manager
/
Patch Compiler
TCP/IP
LIB Manager
Stack Analyzer
PDF Update
ATMEL
AVR
Faculty of Electrical and Electronic Eng. 5 Automatic Control & Automation Dept.
6.
WORDExport to RTF ile
f
.Export to HTML
Bascom-AVR
. .1
2
1- Directives
Directives are special instructions for the compiler. They can override a setting from the IDE.
2- Configuration
Configuration commands initialize the hardware to the desired state.
3- Variables
Dimension all required variables.
4- Main Program
Contains all executive instructions such as: Mathematical Instruction.
5- Sub Routines
They are sub programs or sub procedures, call from the main program
ProgramSyntax Check 3
4
،LOOP ﻳﺘﻮﻗﻊ ﻭﺟﻮﺩ ﺗﻌﻠﻴﻤﺔ
.DOﻫﺬﺍ ﺻﺤﻴﺢ ﻷﻧﻪ ﻳﻮﺟﺪ
6
7. Practical Class 1 Programming Microcontrollers
Program Compile 5
ProgramSend to programmer 6
Bascom-AVR
لﻮ ﻮ ﺗوﺮ
اﻟﴩﻃﻴﺔ ا ﳤﻴﺌﺔ اﻟﺘﺤﻮﯾﻼت اﻟﺘﻮﻗ ﺖ واﻟﺘﺎرﱗ اﻟﺘﺄ ﲑ اﻟﺰﻣﲏ
1-WIRE
اﻟﺘﻌﺎﻣﻞ ﻣﻊ
ﺎ دﻹ اI2Cج ﺮﺧﻹ
ا او ل لﻮ ﻮ ﺗوﺮ ﺗﺼﻨﻴﻒ اﻟﺘﻌﻠ ت ت ﺎﻔﻠﳌا
اﻟﺘﻮﺟﳱﺎ ت
اﻟﱪﳎﻴﺔ ﰲ ﺑ ﺔ اﻟﱪ ﻣﺞ
لﻮ ﻮ ﺗوﺮ اﻟﺘﻌﺎﻣﻞ ﻣﻊ
RS232
اﻟﺘﺤﲂ ﻋﻦ ﺑﻌﺪ Bascom-AVR ةﺮ ا ا
اﻟﺘﺤﲂ ﳌﻌﺎﰿ
ﺪد اﻟﺘﻌﻠ ت ﺰﯾﺪ ﻋﻦ
اﳊ ﺴﺎﺑﻴﺔ لﻮ ﻮ ﺗوﺮ لﻮ ﻮ ﺗوﺮ
واﳌﺜﻠﺜﺎ ت TCP/IP 053 ﺗﻌﻠﳰﺔ اﻟ ﺴﻼﺳﻞ اﶈﺮﻓ ﺔ
SPI
لﻮ ﻮ ﺗوﺮ ر ﺎﻬﻇﻹ ا ﺔﺷ ﺷ
ﺎ ر ﺎﻬﻇﻹ ا ﺔﺷ ﺷ
ﺎ
ت ﺎﻌﻃ ﺎﻘﳌا تﴍ ﺆ ﳌا ﺰ ﻔﻘ ﻟاوت ﳊ ا
ﺎﻘﻠ ا
PS2 ا ﻟﻜ ﺮ ﺴ ﺘ ﺎ ﻟﻴ ﺔ ﺔ ﻣﻮﺳﺮ ﻟا
ISIS Proteus Simulation ISIS Proteus
Faculty of Electrical and Electronic Eng. 7 Automatic Control & Automation Dept.
8.
Proteus
Comparison between most famous µC families
AVR, PIC, 8051
AVR PIC 8051
16MHZ 20MHZ 24MHZ
1Cycle 4Cycle 12Cycle
16/1 = 16MIPS 20/4 = 5MIPS 24/12 = 2MIPS
100% 70% 50%
132 35 215
>256KBytes <64KBytes <32KBytes
Liner banked Liner
CISC/Von
RISC/Harvard RISC/Harvard
Neumann
16 Bit 12 Bit 8 Bit
AVR Microcontrollers Family AVR® 8-Bit
AVR
Automotive AVR
AVR Z-Link IEEE 802.15.4 / ZigBee
Batery M nagem nt A
t a e VR 1.8~25
CAN AVR CANopen, DeviceNet, OSEKCAN
LCD AVR LCD
Lighting AVR
USB AVR USB
Tiny AVR
MEGA AVR 20MIPS
XMEGA AVR 32MIPS
AT90Sxxxx MEGA
8
9. Practical Class 1 Programming Microcontrollers
BatteryM AVR Lighting AVR USB AVR megaAVR tinyAVR
18 ~ 48 Pin 24 ~ 32 Pin 32 ~ 64 Pin 28 ~ 100 Pin 8 ~ 32 Pin
MAX I/O 4~18 MAX I/O 19~27 MAX I/O 22~48 MAX I/O 23~86 MAX I/O 6~28
4KB~40KB Flash 8KB~16KB Flash 8KB~128KB Flash 4KB~256KB Flash 1KB~8KB Flash
256B~1KB EPROM 512B EPROM 512B~4KB EPROM 512B~4KB EPROM 64B~512B EPROM
512B~2KB SRAM 512B~1KB SRAM 512B~8KB SRAM 512B~16KB SRAM 32B~512B SRAM
Up To 8MIPS Up To 16MIPS Up To 16MIPS Up To 20MIPS Up To 20MIPS
1.8V – 25V 2.7V – 5.5V 2.7V – 5.5V 1.8V – 5.5V 1.8V – 5.5V
AVR® 8-Bit
Automotive AVR CAN AVR LCD AVR AVR Z-Link xmegaAVR
14 ~ 64 Pin 64 ~ 100 Pin 44 ~ 100 Pin
MAX I/O 6~54 64 Pin MAX I/O 54~69 MCU Wireless MAX I/O 36~78
2KB~128KB Flash 32KB~128KB Flash 16KB~64KB Flash chipset for: 16KB~384KB Flash
128B~4KB EPROM 1KB~4KB EPROM 512B~2KB EPROM IEEE 802.15.4 1KB~4KB EPROM
128B~4KB SRAM 1K~4KB SRAM 1KB~4KB SRAM and 2KB~32KB SRAM
Up To 16MIPS Up To 16MIPS Up To 20MIPS ZigBee Up To 32MIPS
2.7V – 5.5V 2.7V – 5.5V 1.8V – 5.5V applications. 1.8V – 3.6V
Reading AVR Package information AVR
––AVR
Faculty of Electrical and Electronic Eng. 9 Automatic Control & Automation Dept.
10.
.ATMEL :AT
:Mega
8,16,32,64,128,256, etc…8
2.7V~5.5V L :L
4.5V~5.5V––
2016 :8
:P
SOIC, TQFP, LQFP…PDIP
IC :I
M
10
11. Practical Class 1 Programming Microcontrollers
Reading Datasheet of ICs
– Datasheet –
Bascom-AVR
Assembly
––
Reading Datasheet of ATmega128 ATmega128
Features ·
High-performance, Low-power AVR® 8-bit Microcontroller 8-bit
· Advanced RISC Architecture. RISC ·
– 133 Powerful Instructions Most Single Clock Cycle. 133 –
– 32 x 8 General Purpose Working Registers + Peripheral
+ 32 x 8 –
Control Registers
– Fully Static Operation –
– Up to 16 MIPS Throughput at 16 MHz 16 MHz 16 –
– On-chip 2-cycle Multiplier –
· Nonvolatile Program and Data Memories ·
– 128K Bytes of In-System Reprogrammable Flash 128KB –
Endurance: 10,000 Write/Erase Cycles
10,000
– Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program - True –
Read-While-Write Operation EEPROM 4KB –
– 4K Bytes EEPROM 100,000
Endurance: 100,000 Write/Erase Cycles
SRAM 4KB–
– 4K Bytes Internal SRAM
– Up to 64K Bytes Optional External Memory Space
64KB–
– Programming Lock for Software Security –
– SPI Interface for In-System Programming SPI–
· JTAG (IEEE std. 1149.1 Compliant) Interface JTAG ·
– Boundary-scan Capabilities According to the JTAG Standard
–
– Extensive On-chip Debug Support
–Programming of Flash, EEPROM, Fuses and Lock Bits Debug–
through the JTAG Interface –
Faculty of Electrical and Electronic Eng. 11 Automatic Control & Automation Dept.
12.
·
· Peripheral Features
–Two 8-bit Timer/Counters with Separate Prescalers and 8-bit/–
Compare Modes 16-bit/–
–Two Expanded 16-bit Timer/Counters with Separate
Prescaler, Compare Mode and Capture Mode
–
– Real Time Counter with Separate Oscillator
– Two 8-bit PWM Channels 8-bit PWM–
– 6 PWM Channels with Programmable Resolution from 2 to 16-bit PWM–
16 Bits 162
– Output Compare Modulator
10-bit/–
– 8-channel, 10-bit ADC
– Byte-oriented Two-wire Serial Interface
I2C–
– Dual Programmable Serial USARTs USARTs–
– Master/Slave SPI Serial Interface /SPI–
– Programmable Watchdog Timer with On-chip Oscillator
–
– On-chip Analog Comparator
–
· Special Microcontroller Features ·
– Power-on Reset and Programmable Brown-out Detection –
– Internal Calibrated RC Oscillator –
– External and Internal Interrupt Sources
–
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save,
Power-down, Standby, and Extended Standby –
– Software Selectable Clock Frequency –
– ATmega103 Compatibility Mode Selected by a Fuse ATmega103 –
– Global Pull-up Disable
–
· I/O and Packages / ·
– 53 Programmable I/O Lines-PDIP PDIP/53–
– 64-lead TQFP and 64-pad MLF TQFP/64–
· Operating Voltages ·
– 2.7 - 5.5V for ATmega128L ATmega128L 2.7 - 5.5V –
– 4.5 - 5.5V for ATmega128 ATmega128 4.5 - 5.5V –
· Speed Grades ·
– 0 - 8 MHz for ATmega128L ATmega128L 8-MHz –
– 0 - 16 MHz for ATmega128 ATmega128 16-MHz –
ATmega128
. ATmegaxxx
12
13. Practical Class 1 Programming Microcontrollers
Pin Confgur ations ·
i
PE0(RXD/PDI) 2
PE0 /
JTAG UART
Faculty of Electrical and Electronic Eng. 13 Automatic Control & Automation Dept.
14.
Block Diagram ·
RISC Harvard AVR
14
15. Practical Class 1 Programming Microcontrollers
Standard Systems Design
Von NeumannHarvard
Von-Neumann
·
·
·
·
Harvard
Methods Architecture Systems Design
.(150 ~ 1500 Instruction) Complex Instruction Set Computer : CISC
.(30 ~ 130 Instruction) Reduced Instruction Set Computer : RISC
.(15 ~ 30 Instruction) Minimum Instruction Set Computer :MISC
CISC
Faculty of Electrical and Electronic Eng. 15 Automatic Control & Automation Dept.
16.
AMD& INTEL
RISC
RISC
DSPsMicrocontrollers
µA
MISC
16
17. Practical Class 1 Programming Microcontrollers
AVR Development Board AVR
AVR
50
--
Human-Computer Interaction Methods
.1
.2
/ .3
.4
.5
.LCD 20x4 .6
GLCD 128x64 .7
Faculty of Electrical and Electronic Eng. 17 Automatic Control & Automation Dept.
18.
.8
DTMF .9
.10
.11
.RC5, RC5-Extended .12
.RC5, RC5-Extended .13
0 – 9 .14
.0 – 9999 .15
RS232UART1 .16
UART2 .17
RS485 .18
.19
.20
.21
.LM35DZ-45⁰C ~ +100⁰C .22
ADCNTC .23
.24
.ADC .25
.26
.27
.28
PWM .29
.30
.31
.32
DACLadder .33
DAC .34
18
19. Practical Class 1 Programming Microcontrollers
.35
RTC .36
.EEPROM .37
.38
Overflow, Compare & Capture modes .39
MMC .40
Smart Card .41
PS2 .42
PS2 .43
DS18211-Wire .44
LED-Matrix Displays .45
USARTRS232 .46
EEPROM .47
.48
.49
.50
.51
.JTAG .52
.53
ESD, EMC & EMIPCBs .54
RTSMultitasking .55
.56
SPI .57
Faculty of Electrical and Electronic Eng. 19 Automatic Control & Automation Dept.
20.
AVR Development Board Designing schedule
AVR -1
-2
-3
-4
Embedded EMC,EMR,ESD
Systems
Proteus -5
compilers -1
AVR
In System Programming -2
-3
10060 -4
-5
Embedded Systems Design
self learners -6
-7
،USD120
.USD700
20
21. Practical Class 1 Programming Microcontrollers
-8
Lab-Center Proteus-7.2
Bascom-AVR
Debugger -9
RS232 Interface
-10
48 I/O
AVR -11
SPI
-12
-13
5% : a
85% b
c
90%
96% d
.98% e
f
1507045%
-14
-15
Open Source
LabVIEW, VB6, Matlab, etc… -16
Faculty of Electrical and Electronic Eng. 21 Automatic Control & Automation Dept.
22.
Development Board Layout Diagram
22
23. Practical Class 1 Programming Microcontrollers
Development Board Schematic & Board Design
Faculty of Electrical and Electronic Eng. 23 Automatic Control & Automation Dept.
24.
24
25. Practical Class 1 Programming Microcontrollers
Faculty of Electrical and Electronic Eng. 25 Automatic Control & Automation Dept.
26.
26
27. Practical Class 1 Programming Microcontrollers
USART
Faculty of Electrical and Electronic Eng. 27 Automatic Control & Automation Dept.
28.
EEPROM & RTC I2C
28
29. Practical Class 1 Programming Microcontrollers
RS485
Faculty of Electrical and Electronic Eng. 29 Automatic Control & Automation Dept.
30.
30
31. Practical Class 1 Programming Microcontrollers
MMC/SD
PWM
Faculty of Electrical and Electronic Eng. 31 Automatic Control & Automation Dept.
32.
PS2
32
33. Practical Class 1 Programming Microcontrollers
1-Wire
Faculty of Electrical and Electronic Eng. 33 Automatic Control & Automation Dept.
34.
34
35. Practical Class 1 Programming Microcontrollers
Faculty of Electrical and Electronic Eng. 35 Automatic Control & Automation Dept.