Title: Microcontrollers MCS51 and AVR
1MicrocontrollersMCS51 and AVR
Degree of confidentiality
2PCs and Microcontrollers
- Personal Computer
- Keyboard, monitor, CPU, printer, mouse
- Communicate (interface) with humans
- Microcontrollers
- Micro because theyre small
- Controller because they control machines,
gadgets, instruments, etc. - Integrated circuit
- Contains many of the same items that a desktop PC
has CPU, memory, interfaces etc. - Not include any human interface
- Designed for machine control applications, rather
than human interaction
3Microcontrollers
- A microcontroller is a computer-on-a-chip, or, a
single-chip computer - Primarily, the microcontroller is capable of
storing and running a program - Contains
- CPU
- RAM/ROM
- I/O lines
- serial and parallel ports
- timers
- other built-in peripherals such as A/D and D/A
converters
4MCS51
- 8051, developed by Intel in 1980
- Harvard architecture single chip microcontroller
(physically separate storage and signal pathways
for their instructions and data ) - Typically contains
- Processor (CPU). The original 8051 core ran at 12
clock cycles per machine cycle, with most
instructions executing in one or two machine
cycles - 8 bit data bus. Can access 8 bit data in one
operation - 16 bit address bus. Can access 64 KB of memory
each of RAM and ROM - On chip RAM - 128 or 256 bytes Bytes (Data
Memory) - On chip Program Memory - 512 bytes to 128kb
- Four Bit bi-directional Input Output port
- One or two Serial Ports (UARTs)
- Two or three timers
- Two level interrupt priority
- Power saving mode
5MCS51
- Common features included in modern 8051 based
microcontrollers - built-in reset timers with brown-out detection
- on-chip oscillators
- self-programmable Flash ROM program memory
- bootloader code in ROM
- EEPROM non-volatile data storage
- I2C, SPI, and USB host interfaces
- PWM generators, analog comparators, A/D and D/A
converters - RTCs, extra counters and timers
- in-circuit debugging facilities
- more interrupt sources
- extra power saving modes
- Several C compilers are available for the 8051
- Other high level languages such as Forth, BASIC,
PASCAL, PL/M and Modula 2 are available - Single cycle 8051 cores, in the range 130 MHz to
150 MHz, are now available in internet
downloadable form for use in programmable logic
devices such as FPGAs and at many hundreds of MHz
in ASICs
6Atmel 8051 architecture
7Arithmetic Instructions
- For example, the ADD A, ltbytegt instruction can be
written as - ADD A,7FH (direct addressing)
- ADD A,_at_ R0(indirect addressing)
- ADD A,R7 (register addressing)
- ADD A, 127(immediate constant)
8Data Transfers and Boolean Instructions
9Programming example
bseg at 0 at bit 0 cseg at 0 jmp main
org 23h jmp isr_serial isr_serial
serial handler jb ri,receptie clr p3.7
set RX on 485 clr ti end_trs jb ri,receptie
reti receptie
receive handler clr ri mov a,sbuf jb
at,readaddr cjne a,65,noatent jmp atention
-------------- read address ------------------
readaddr cjne a,2,nodevice mov r7,30 wtt0
mov r6,255 wtt1 djnz r6,wtt1
djnz r7,wtt0 mov a,p1 setb p3.7 mov sbuf,
a nodevice clr at reti noatent
reti
10Programming example
-------------- set atention flag
--------------- atention setb at reti main
mov r0,7fh clear mov _at_r0,0 djnz r0,c
lear clear memory mov sp,70h set
stack pointer clr p3.7 set RX on
485 call ini call init loop wait for
events jmp loop ------------------- serial
initialization --------- ini mov scon,5ch
mov tmod,20h mov th1,0fdh mov pcon,80h
setb tr1 mov ie,90h ret end
11ADuC microcontroller
12AVR
- Family of RISC microcontrollers from Atmel
(reduced instruction set computer, favors a
simpler set of instructions that all take about
the same amount of time to execute) - Program instructions are stored in semi-permanent
Flash memory which loads and manipulates data in
the volatile SRAM - The AVRs have thirty-two single-byte registers.
- Two-stage pipeline design
- Most instructions take just one or two clock
cycles - The AVRs were designed for the efficient
execution of compiled C code
13AVRs features
- RISC Core Running Many Single-Cycle Instructions
- Multifunction, Bi-directional I/O Ports with
Internal, Configurable Pull-up Resistors - Internal Oscillators
- Internal Instruction Flash Memory up to 256K
- Internal Data EEPROM up to 4KB
- Internal SRAM up to 8K
- 8-Bit and 16-Bit Timers
- PWM Channels
- Dedicated I2C Compatible Two-Wire Interface
- Synchronous/Asynchronous Serial Peripherals
(UART/USART) - Serial Peripheral Interface (SPI)
- Analog Comparators
- 10-Bit A/D Converters
- Brownout Detection
- Watchdog Timer (WDT)
14AVRs features
- Low-voltage Devices Operating Down to 1.8v
- Universial Serial Interface for Two-Wire,
Three-Wire Synchronous Data Transfer - picoPower Devices
- CAN Controller Support
- Lighting (PWM Specific) Devices
- USB Controller Support
- LCD Controller Support
- Ethernet Controller Support
- Multiple Power-Saving Sleep Modes
15AVR Architecture
16AVR Instructions
17GeMASYS
18Domocontroller
19Energy monitoring
Second card
First card
20Other embedeed systemsGumstix
21References
- www.atmel.com
- http//microcontroller.com/
- http//www.8052.com/tut8051.phtml
- http//www.avrfreaks.net/
- http//winavr.sourceforge.net/
- http//avr.15.forumer.com/index.php?showforum10
- http//sdcc.sourceforge.net/
- https//gumstix.com/index.html