microcontroller basics
TRANSCRIPT
![Page 1: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/1.jpg)
What is a Microcontroller?
A microcontroller (sometimes abbreviated µC or MCU) is a small computer on a single IC containing a processor core, memory, and programmable input/output peripherals.
It is a decision making device used widely in embedded systems and all intelligent devices.
![Page 2: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/2.jpg)
Basic Block Diagram of Microcontroller
![Page 3: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/3.jpg)
Difference between Microcontroller and Microprocessor
Microcontroller has I/O ports, Memory, timers etc all integrated on chip itself
In Microprocessors, I/O ports, memory, timer etc are to be connected externally
![Page 4: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/4.jpg)
Block Diagram to show the difference
![Page 5: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/5.jpg)
What is a 8-bit microcontroller?
8-bit means it can process 8-bit data per clock cycle
It has 8-bit data bus
It can process 1byte of data at a time
![Page 6: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/6.jpg)
AVR ATmega8 Microcontroller
![Page 7: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/7.jpg)
How AVR ATmega8 got its name?
It was developed by Atmel Corporation
AVR implies it belongs to AVR family.
‘8’ in Atmega8 means this microcontroller has 8Kb of flash memory
![Page 8: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/8.jpg)
What is AVR?
AVR is a modified Harvard architecture , 8-bit RISC single chip microcontroller.
It was developed in the year 1996 by Atmel Corporation.
![Page 9: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/9.jpg)
What’s special about AVR?They are fast.
AVR Microcontroller executes most of the instructions in single execution cycle.
AVRs are about 4 times faster than PIC.
They consume less power and can be operated in different power saving modes.
![Page 10: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/10.jpg)
What is RISC?RISC stands for “Reduced Instruction Set
Computer”.
It is a very fast architecture which executes one instruction per clock cycle.
RISC contains very small instruction set.
Programming is easy, but code length increases.
![Page 11: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/11.jpg)
Harvard and Von Neumann Architecture
![Page 12: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/12.jpg)
Harvard Architecture
Harvard architecture has separate data and instruction buses.
This allows transfers to be performed simultaneously on both buses.
![Page 13: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/13.jpg)
Von Neumann Architecture
A Von Neumann architecture has only one bus which is used for both data transfers and instruction fetch
Data transfers and instruction fetches must be scheduled as they cannot be performed at the same time
![Page 14: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/14.jpg)
Introduction to Atmega8
ATmega8 is a low-power CMOS 8-bit microcontroller based on the AVR RISC architecture.
By executing powerful instructions in a single clock cycle, the ATmega8 achieves throughput approaching 1 MIPS per MHz
In order to maximize performance and parallelism, the AVR uses a Harvard architecture.
![Page 15: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/15.jpg)
Features Of ATmega8High-performance, Low-power AVR 8-bit
MicrocontrollerUp to 16 MIPS Throughput at 16 MHz32 x 8 General Purpose Working RegistersInternal Calibrated RC OscillatorExternal and Internal Interrupt SourcesData retention: 20 years at 85°C/100 years at
25°C
![Page 16: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/16.jpg)
Memory Segments
8K Bytes of In-System Self-programmable Flash program memory
512 Bytes EEPROM (Electrically Erasable Programmable Read Only Memory)
1K Byte Internal SRAM (Static Random Access Memory)
![Page 17: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/17.jpg)
Peripheral Features Two 8-bit Timer/Counters with Separate Prescaler, one
Compare Mode. One 16-bit Timer/Counter with Separate Prescaler,
Compare Mode, and Capture Mode. Real Time Counter with Separate Oscillator. Three PWM Channels. 8-channel ADC in TQFP package .
![Page 18: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/18.jpg)
Continued…
6-channel ADC in PDIP package.Byte-oriented Two-wire Serial Interface.Programmable Serial USART.Master/Slave SPI Serial Interface.Programmable Watchdog Timer with Separate
On-chip Oscillator.On-chip Analog Comparator.
![Page 19: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/19.jpg)
TYPES OF PACKAGES
28-lead PDIP (Plastic Dual In-line Package)
32-lead TQFP (Thin Quad film Package)
![Page 20: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/20.jpg)
How ATmega8 PDIP Package looks like?
![Page 21: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/21.jpg)
How ATmega8 TQFP Package looks like?
![Page 22: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/22.jpg)
Pinout of ATmega8
![Page 23: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/23.jpg)
Pin DescriptionVCC: Digital supply voltage 5V.GND: Ground.RESET: A low level on this pin for longer than
the minimum pulse length will generate a reset, even if the clock is not running.
AREF: The analog reference pin for the A/D Converter.
![Page 24: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/24.jpg)
Continued….
AVCC : The supply voltage pin for the A/D Converter, Port C (3..0).It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.
![Page 25: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/25.jpg)
PORTS There are 3 ports in ATmega8: Port B, Port C,
Port D.Three registers are associated with every portDDRx – Data Direction RegisterPINx – Port inputPORTx- Port output
Where x would be either B,C or D.
![Page 26: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/26.jpg)
PORT B(PB7-PB0)
It is a 8-bit bi-directional I/O port.It has internal pull up resistors(selected for
each bit).It can be used either as a input port or as
output port ( direction must be specified in programming).
![Page 27: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/27.jpg)
PORT C(PC6-PC0)
It is a 7-bit bi-directional I/O port.It has internal pull up resistors(selected for
each bit).It can be used either as a input port or as
output port ( direction must be specified in programming).
![Page 28: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/28.jpg)
PORTD(PD7-PD0)
It is a 8-bit bi-directional I/O port.It has internal pull up resistors(selected for
each bit).It can be used either as a input port or as
output port ( direction must be specified in programming).
![Page 29: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/29.jpg)
Registers to Communicate with I/O Ports
To communicate with the ports of Atmega8, we use three registers:
PINx PORTx DDRx
Where x would be either B,C or D.
![Page 30: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/30.jpg)
REGISTER DESCRIPTION OF I/O PORTS
![Page 31: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/31.jpg)
Continued…
![Page 32: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/32.jpg)
Continued....
![Page 33: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/33.jpg)
Continued....
![Page 34: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/34.jpg)
Continued....
![Page 35: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/35.jpg)
DDRx Register
It stands for Data Direction Register.It is used to define Port as Input or Output.In order to make Port as Input Port:
DDRx=0x00 (In Hexadecimal) DDRx=0b00000000(In Binary)In order to make Port as output Port:
DDRx=0xFF (In Hexadecimal) DDRx=0b11111111(In Binary)
![Page 36: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/36.jpg)
PORTx RegisterIf DDRx=0xFF(Output port) Writing logic 1 to PORTx will make output
high i.e 5v for that particular pin.
Writing 0 to PORTx will make output low i.e 0v for that particular pin.
![Page 37: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/37.jpg)
Continued..If DDRx=Ox00(Input port): If corresponding PORTx bit is set to 1, Internal
pull up resistors are enabled i.e if we do not connect this pin to anything it still reads as 1.
If corresponding PORTx bit is set to 0, internal pull up resistors are disabled i.e the pin will enter a high impedance state and will become unpredictable.
![Page 38: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/38.jpg)
PINx Register
It reads data from the port pins.If any/all bits of DDRx is set to 0(input)for a
particular pin, we can read data from PINxIf any/all bits of DDRx is set to 1(output), then
reading PINx register gives the same data which has been output on that particular pin.
![Page 39: microcontroller basics](https://reader035.vdocuments.site/reader035/viewer/2022081604/58a346491a28ab62248b59dd/html5/thumbnails/39.jpg)
THANK YOU