Welcome To Day 2 !

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Welcome to Day 2 !

Topics to be covered:
1. Microcontroller Architecture
2. Difference between microcontroller and microprocessor

0 3.
4.
AVR microcontrollers
Bits and Bytes
5. Bitwise operators
6. Registers
7. Types of registers
8. Data Sheet
9. Example: Generating a pwm signal
Microcontrollers &
Microprocessors
Microprocessor consists of only a Central Processing Unit, whereas
Micro Controller contains a CPU, Memory, I/O all integrated into one
chip. Microprocessor uses an external bus to interface to RAM,

1 ROM, and other peripherals, on the other hand, Microcontroller uses


an internal controlling bus

Microcontroller incorporates all of the necessary computing


components onto a single chip. The CPU, memory, interrupt
controls, timer, serial ports, bus controls, I/O peripheral ports, and
any other necessary components are all present on the same chip
and no external circuits are required. The microcontroller is
designed for a specific task and once the program is embed on
MCU chip, it can't be altered easily and you may be needed special
tools to reburn it.
Microcontrollers &
Microprocessors
Microprocessor consists of a CPU and several supporting chips that
supply the memory, serial interface, inputs and outputs, timers, and

2 other necessary components.


That chip can connect to other external peripherals such as a
control bus or data bus that provide binary data inputs and receive
outputs from the microprocessor (also in binary).

The key difference here is that microcontrollers are self-contained.


All of the necessary computing peripherals are internal to the chip,
where microprocessors deal with external peripherals
Now let’s deep dive into
AVR microcontroller!
AVR Micro
controller
AVR was one of the first
microcontroller families to use
on-chip flash memory for program
storage, as opposed to one-time

3 programmable ROM, EPROM, or


EEPROM used by other
microcontrollers at the time.

1. The CPU components are


shaded blue.
2. The memory components are
shaded green.
3. The clock components are
shaded in orange.
4. The I/O components are shaded
in purple.
Oops! What is EPROM,
EEPROM, ROM…………………..
1. ROM : Read only memory is non-volatile memory that permanently
stores instructions for your computer
2. EPROM : erasable programmable read-only memory, can be erased

4 3.
by exposing it to strong ultraviolet light source (mercury-vapor lamp)
EEPROM : Electrically erasable programmable read-only memory
device, a negative pulse is applied, which causes the electrons to
tunnel back out and return the floating gate to near its original state.
4. Flash memory : Flash memory is intermediate between EPROM and
EEPROM, like EEPROM, flash memory uses an electrical erasing
technology. An entire flash memory can be erased in one or a few
seconds, which is much faster than EPROM. Flash memory does not
provide byte-level erasure
Have you ever worked with
an AVR processor?

Yes you have!

Arduino UNO
(DIY 😂)
The Arduino is an AVR processor running special code that
lets you use the Arduino environment to program and upload
code easily.
What does an arduino
development board look like?
● Power (USB / Barrel Jack)
● 5.5 V & 3V
● GND
● AREF
● Analog pins
● Digital pins
● PWM pins
● Power LED indicator
● TX RX LEDs
● Main IC
How to connect these
pins?
→ Permanent soldering

→ Breadboard
How to program these
AVR Microcontrollers
Good news!!

Not at all traditional


programming so don’t
worry!

12
1. The AVR's program is stored in nonvolatile (persistent on
power-down) programmable Flash memory. It is divided into 2
sections. The first section is the Application Flash section. It is where
the AVR's program is stored. The second section is called the Boot
Flash section and can be set to execute immediately when the device

4 2.
is powered up.
All the code you write is linked, assembled and otherwise compiled
into hex code, (also known as byte code) which is a series of
hexadecimal numbers that are interpreted as instructions by the
microcontroller.
3. Can be programmed using Arduino IDE or AVR studio 4
Let’s learn to program
an arduino using
arduino IDE
● setup() function
● loop() function
● pinMode()
● digitalRead()
● digitalWrite()
● analogWrite()
And many more…..

Let’s play around a little

Start tinkering
your circuits!!!
For AVR programming you
need to use datasheet for
which you need to know
4 how to read it. So let’s take
some time to learn “ABCD”
of embedded
Before starting with AVR programming, Let’s learn about registers
The AVR's data memory is volatile RAM. It is organized in 8-bit
registers.All information in the microcontroller, from the program
memory, the timer information, to the state on any of input or
output pins, is stored in registers. Registers are like shelves in the
bookshelf of processor memory. In an 8-bit processor, like the one
we are using, the shelf can hold 8 books, where each book is a one
bit binary number, a 0 or 1. Each shelf has an address so that the
controller knows where to find it. Some registers, such as those in
RAM, are for storing general data. Others have specific functions
like controlling the A/D converters or timers, or setting and getting
values on the I/O pins. Registers in RAM can be read or written.
Other registers may be read-only or write-only. In fact, some
specialized registers may have certain bits that are only to be
read, and certain bits that are only to be written.
Bitwise operators

Operates in every bit of an 8-bit register.

A = 10010110
B = 11110001
A|B = ?
To write 0 in bit c of register A: A = A&(~(1<<c))
To write 1 in bit c of register A: A=A|(1<<c)
You are all set to learn
AVR coding!!!
See you tomorrow!!!
Thank you!

You might also like