0% found this document useful (0 votes)
23 views65 pages

Microcontroller Course Overview and Concepts

The document outlines a course on microcontrollers, detailing prerequisites, applications, and various programmable systems including ASICs and FPGAs. It covers the architecture of microcontrollers, including their internal components, types of processors (CISC and RISC), and memory types. Additionally, it discusses the operation modes, programming languages, and a specific focus on the Microchip PIC family of microcontrollers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views65 pages

Microcontroller Course Overview and Concepts

The document outlines a course on microcontrollers, detailing prerequisites, applications, and various programmable systems including ASICs and FPGAs. It covers the architecture of microcontrollers, including their internal components, types of processors (CISC and RISC), and memory types. Additionally, it discusses the operation modes, programming languages, and a specific focus on the Microchip PIC family of microcontrollers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Higher School of Management of Computer Science and

School of Sciences (ESGIS)


*******

Course: Microcontroller

Prof: Justin AKORO


Evaluation

Project to be submitted

Participation note for the course and the tutorials


Prerequisites

. The different number bases (binary, octal, decimal, hexadecimal)

. Conversions and operations on binary numbers

. Concepts of digital electronics (combinational and sequential logic functions)

. General electronics and electricity


Generalities

Industrial computing
is a branch of
applied computing that
covers the entire
design techniques and
programming of systems
computerized for a purpose
industrial, which are not
of computers. » (Source :
Wikipedia
Industrial computing

Applications:

Automation, robotics
● Measurementsofphysicalquantities,

Real-time systems,

Embedded systems.

Ascom S.A.
The different programmable systems

Specialized circuits or ASIC (Application Specific Integrated Circuit):

ASIC circuits are specialized circuits designed from the outset for a specific application.
data.

Examples: DSP (Digital Signal Processing), arithmetic co-processor

Texas Instruments

Advantages: Inconvénients :

Veryfast ●
Lowmodularity

Lowerconsumption ●
Limited possibility of evolution

Optimized for an application ●
Cost
The different programmable systems
• Systems in programmed logic and/or programmable logic are known as the
designation of PLD (programmable logic device, programmable logic circuit)


FPGA (field-programmable gate array, in-situ programmable gate network)

PAL (programmable array logic, programmable logic network)

...

Source: Altera Source: Altera

A programmable logic circuit, or programmable logic network, is a logic integrated circuit.


which can be reprogrammed after its manufacture. It is made up of numerous logic cells
elementary components that can be freely assembled." (Wikipedia)

Advantages: Disadvantages:

Strongmodularity ●
More complex implementation

Speed ●
High development costs
Processors

Two types of processors


CISC: Complex Instruction Set Computer

Large number of instructions,


Mostcommontypeofprocessor


RISC: Reduced Instruction Set Computer

Reduced number of instructions


(selection of instructions for faster execution)
Faster instruction decoding
Evolution of processors

Intel Pentium 4 Northwood C(2002)


42 million transistors, etched at 0.13 µm
32-bit internal architecture
clock frequency 2.4/3.4 GHz
(bus processor: 200MHz)
Source: Intel

Source: Intel

Intel 8086 (1978)


39,000 transistors, etched in 3µm
internal architecture 16
bits bus 16 bits
clock frequency 4.77/10 MHz
Evolution of processors

• Intel Core i7 Ivy


bridge(Sept. 2013)
• 1.4 billion transistors, etched in

22nm
• internal architecture 64
bits 4/12 cores
• clock frequency 4.0
GHz
• Bus frequency: 0.2 GHz
Intel Pentium 4 Northwood C (2002)
42 million transistors, etched at 0.13 µm
32-bit internal architecture
clock frequency 2.4/3.4 GHz
Bus frequency: 0.2 GHz
Wired logic:

• ["TRUE","FALSE"]
• NO, YES
• AND
• NON-ET (NAND)
• OR

STI2D Sin
Wired logic:

Two families:

• microprocessor

• microcontroller.
Cabled Vs Programmed

La logique programmée offre un énorme avenage sur la logique câblée:

we change the functioning of a system by simple modification of the


program.
. Microprocessor and peripherals
. With a microcontroller, everything is integrated.
HIGH LEVEL LANGUAGE SOURCE
TYPE C, C++, JAVA ETC ...

LOW LANGUAGE
COMPILATION LEVEL
ASSEMBLER

PROGRAMME.c

CODING IN
MACHINE LANGUAGE

PROGRAMMING LIBRARY

DOWNLOAD

LIBRARY.h
Microcontroller
Controller
a controller is a device that - placed at the heart of a process -
monitor the evolution of an event and compare its state (or value) to
a predetermined data, to intervene as soon as the set limits
are affected.

His job involves monitoring (reading) the value of a situation, and to


constantly compared to a predetermined value.
Microcontroller

The most flexible of all controllers are obviously the controllers.


drawing on electronics, and more specifically microcontrollers

According to a French decree of September 14, 1990 relating to terminology of


electronic components "Integrated circuit mainly consisting of a
microprocessor, its memories, and custom elements according to
the application

19
Microcontroller
Integrated circuit
Microcontroller architecture

Placing in situation
Microcontroller Architecture

A technical object, incorporating electronics, often reveals functions.


having the role of processing information: arithmetic operations (addition,
multiplication...) or logical (AND, OR...) between several input signals allowing
to generate output signals.

These functions can be performed by analog or logic integrated circuits.


But when the technical object becomes complex, it then becomes necessary to realize
a significant set of information processing, it becomes easier to do
call to a microcontroller-based structure.
Microcontroller architecture

Internal structure
A microcontroller comes in the form of an integrated circuit that brings together all the elements.
of a microprocessor-based structure.
Hereisgenerallywhatyoufindinsidesuchacomponent:

A microprocessor (C.P.U.)
From data memory (RAM and EEPROM),
From program memory (ROM),
Parallel interfaces for connecting inputs/outputs,
Serial interfaces (synchronous or asynchronous) for communication with others
units
Timers to generate or measure signals with high precision
temporal
Analog to digital converters for signal processing
analog
Internal structure
• Von Neumann architecture
The previous functional diagram represents a "Von Neumann" architecture (Common
to most microprocessors) where the program memory shares the same bus as the
data memory.

The architecture of 'Harvard', which has separate buses for data and for
program is used less often.
• C.P.U. (MICROPROCESSOR).

A microprocessor sequentially executes the instructions stored in memory.


program. It is capable of operating on binary words whose size, in bits, is that of
data bus.

It generally consists of the following elements:


. One or more accumulator registers temporarily containing the
operands as well as the results of the operations,

. Auxiliary registers that allow relaying the accumulators,

. Index registers for indirect addressing mode,

. A counter program pointing to the address of the next instruction at


execute, its size is that of the address bus,

. An arithmetic and logic unit (ALU) that allows for performing operations
between the accumulator and an operand,
. A register code condition indicating certain specifics regarding
concerning the result of the last operation (hold, zero, interruption...).

It can be noted that there are 2 categories of microprocessors: CISC and RISC.

CISC (Complex Instruction Set Computer): This microprocessor has a


large number of instructions. Each of them is executed over several periods
of clocks.

RISC (Reduced Instruction Set Computer): This microprocessor has a


reduced number of instructions. Each of them is executed in a period
of the clock.
. Memory programs
This device contains the program instructions that the microprocessor must execute.
type of memory (called read-only memory), is only accessible in reading.

There are different types according to their programming mode:

ROMs (Read Only Memory) whose content is defined during manufacture.

PROMs (Programmable Read Only Memory) are programmable by the user.


but only once.

EPROMs (Erasable Programmable Read Only Memory) are programmable by


the user. Erasable by a special machine, the memory must therefore be easily
table of its support.

EEPROM (Electrically Erasable Programmable Read Only Memory) are


user-programmable. They are electrically erasable.
. Data memories

This device allows for the temporary storage of data generated by the
microprocessor during the various phases of digital processing (results
operations, sensor states...). These memories are accessible for writing and reading.

There are 2 types found:


Volatile random access memory (RAM) (data lost in case of power outage)
the memory) having a relatively short read and write time (a few ns),

From non-volatile EEPROM (data retained in case of power failure)


the power supply) having a relatively high writing time (a few ms) compared to the time
of reading which is quite low (a few ns).
. Parallel interface
This type of interface, distributed over several ports (maximum 8 bits), allows for taking in
count of logical states applied at input (sensor state) or to generate signals
binary outputs (actuator commands).

The pins of these ports can therefore be configured as input or output, with
different options (pull-up resistors, open collector outputs, interruption...).

The configuration as well as the logical state of these pins is obtained through operations.
of writing or reading in different registers associated with each port.

We generally find:

A direction register for input or output configuration,

A data register replicating the logical states of each port pin,

An option register allowing multiple configurations for input or output.


. Serial interface
This type of interface allows the microcontroller to communicate with other systems.
microprocessor base. The data sent or received is presented in the form of a
temporal succession (on a single bit) of binary values images of a word.

There are 2 types of serial communication: synchronous and asynchronous.

synchronous series connection

In this device, the transmission is synchronized by a clock signal emitted by the unit.
master.
. Serial interface
asynchronous series liaison
This device does not have a synchronization clock signal. The units are linked.
each have an internal clock running at the same frequency.

When a unit wants to emit a binary word, it generates a falling edge on its line.
emitter. At the end of the broadcast of this word, the line returns to the high level.

The data to be transmitted may contain an additional bit called 'parity' which is used for the
correction of errors.
. Serial interface
Parameters involved for the RS232 standard:

Word length: 7 bits (e.g., ASCII character) or 8 bits

The transmission speed: it is defined in bits per second or bauds. It


can take values ranging from 110 to 115,200 bds.

Parity: the transmitted bit may or may not be followed by a parity bit that is used to
detect any potential transmission errors.

Bit start: the idle line is in logical state 1 to indicate that a word will be
bring the line low before starting the transfer.

Bit of stop: after transmission, the line is positioned at rest for 1, 2

Voltage level: A logical '0' is represented by a voltage between 3


and 25V, a '1' by a voltage between -25 and -3V.
. CAN

The CAN integrated into microcontrollers is generally of the "Approximations" type.


successive”. It has multiple multiplexed inputs accessible via the pins of the ports
from the parallel interface. The ADC normally has 2 registers:

A data record containing the result of the conversion,

A control register for initiating and monitoring the conversion.

. The Timer
Its role is to enable the synchronization of the operations that the microcontroller is
in charge of carrying out.

Several registers associated with the Timer allow for the configuration of the different described modes.
previously.
. THE GUARD DOG.

This device is an anti-crash system for the microcontroller. It ensures that there is no
prolonged execution of the same sequence of instructions.

. Clock signals

The clock signal allows the microcontroller to be clocked.

To obtain it, a quartz is placed between the two pins 'OscIn' and 'OscOut' as
The following diagram indicates:
MODE OF OPERATION.

The microprocessor sequentially executes instructions encoded in binary and


present in the program memory. The initialization of this sequence can be done by
different ways depending on the mode of operation.

. Interrupt-driven operation

The microcontroller, in its environment, is designed to process information in


real time”. The application is linked to the outside world through frequent exchanges of
messages and signals at scheduled times. He is obliged to change state at
function of the relative priorities of the ongoing operation and the one being requested. It
interrupts or not the normal course of the program based on an external request.

These are seen from the microcontroller as interrupt requests. It is noted


two types of interruption:
- NMI (No Maskable Interrupt): non-maskable interrupt

- - IRQ (Interrupt Request): maskable interrupt.


Regardless of the activated interrupt source, the microprocessor performs
identical tasks:

In any case, the main program is interrupted;

- the processor must save the contents of the PC in the stack;

- the processor executes a privileged sequence, reflecting the type of processing


of interruption;

- The consideration of an interruption never occurs during the execution of a


instruction.
. INITIALIZATION: . RESET
. INSTRUCTIONS AND ADDRESSING MODES.

The instructions contained in the program memory are a sequence of binary words.
decoded and then executed by the microprocessor, called machine language. These codes are
difficult to understand by the programmer. This is the reason why they are
translate into different words that are part of assembly language.

Addressing modes are the different ways that allow the microprocessor
to access an operand in order to test or modify the content of a register or a
memory.
Description and programming of the task to be accomplished.

The specifications define all the commands or actions that must be carried out.
the microcontroller. Before generating the binary machine code understandable by the
microcontroller, intermediate steps are necessary to reduce risks
of errors and difficulties.

First, we display the operating cycle using two representations.


standardized: the algorithm and the algorigram. We can then write the program
associated using different languages:

An advanced language (C, Pascal, and Basic) using procedures suited to the type of
microprocessor and is translated into machine code by a compilation operation
performed by a "Cross-compiler".

. Normalized representation: the algorithm is established through a succession of phrases


simple.
Microcontroller family

There are several families of microcontrollers:

The familyAtmelAT91 The K0 family ofNEC.


The familyAtmelAVR.
The V800 family ofNEC.
TheC167ofSiemens.
The familyLPC21xxARM7-TDMIof
The familyHitachi H8. Philips.

The family ofPICofMicrochip.

The family ofDSPICofMicrochip.

The familyPSOCofCyprus.
Study of the Microchip PIC family

Peripheral Interface Controller

A PIC is a microcontroller, it is a type of information processing unit.


microprocessor to which internal peripherals have been added to facilitate
the interfacing with the outside world without requiring the addition of external components.

PICs are RISC (Reduced Instruction Set Computing) components or


component with a reduced instruction set. The advantage is that the more we reduce the number
the instructions, the easier and faster the decoding is, and the quicker the component
works
Study of the Microchip PIC family

The family of woodpeckers is subdivided into three major families:

Base-line: it is a family that uses 12-bit instruction words.

Mid-range: it is a family that uses 14-bit words (which include the


16F84, 16F876 and 16F877

High-end: it's a family that uses 16-bit words.

There are also 16-bit (PIC24F/PIC24H) and 32-bit (PIC32M) microcontrollers.


also. All Mid-Range PICs have a set of 35 instructions, storing each
instruction in a single word of program, and execute each instruction (except the
jumps) in a machine cycle.
Study of the Microchip PIC family

Identification of a Peak
Study of PIC 16F877:

Internal organization of the PIC 16f877

The internal architecture of the PIC16f877 is mainly composed of registers that have
each with a well-defined function. The PIC also has built-in peripherals, such
an EEPROM memory, three timers, input/output ports or converter
analog/digital
Study of PIC 16F877:

External organization of the PIC 16f877

The PIC16F877 is a 40-pin integrated circuit:


. The entry/exit ports
The numbers 7 and 9 are the only ones that can be represented in two ways: by lighting up
segments A, B, and C (as in this table) or quite rarely A, B, C, and F for the 7,
and by lighting segments A, B, C, D, F, and G (as shown on this table) or A, B, C, F, and G
(as shown in the animation opposite) for number 9.

Ces chiffres décimaux peuvent être complétés par les lettres A à F pour la numération
hexadecimal:
Library for LCD

Programming an LCD screen in parallel or serial mode is


generally a complex task and requires a good understanding of
internal operation of the LCD screen. The mikroC language provides functions for the
two modes of text-based programming already prepared, which simplifies use
of LCD screens.

The HD44780 LCD controller

The HD44780 is one of the most appreciated liquid crystal controllers, being used
in the industry and in commercial applications.

Modules with 8, 16, 20, 24, 32, and 40 characters are available. Depending on the model,
The LCD screen is made with 14 or 16 pins for the interface.
Description
Description
The VSS pin is at 0V or ground. The VDD pin must be connected to the positive terminal.
power supply. Although manufacturers specify a 5V DC power supply,

The 3 VEE leg is designated for adjusting the display contrast and must be connected to a
DC power supply. A potentiometer is usually connected to
the power supply with its slider connected to the VEE pin and the other pin of the potentiometer connected
to the masses.

Leg 4: is the selection register (RS). When RS is at +5V, the data from
Characters can be transferred from the LCD module.

Pin 5 is the read/write selection register (R/W). This pin is connected to


the mass (low logic state) in order to write character data to the LCD module. When
this pin is at +5 V (high logic state) so the information coming out of the LCD module
can be read.
Description

The leg 6 is validation (EN), which is used to initiate the transfer of orders or
of data between the module and the microcontroller.

Pins 7 to 14 are the eight data bus lines (D0 to D7). The data can
to be transferred between the microcontroller and the LCD module using either a single 8-bit byte
bits can be of two 4-bits. In this last case, only the four upper data lines
(D4 to D7) are used..

The mikroC LCD library provides a large number of functions to control


LCD text with 4-bits and 8-bit data interfaces, and for graphical LCDs. The
the most common are the 4-bit text mode interfaces on LCD screens. The following are the
available functions for 4-bit LCD interface in text mode:
Description

The name of the port must be specified by passing its address. For example, if RS leg is
connected to RB0, EN pin to RB1, D7 pin to RB2, D6 pin to RB3, D5 pin to RB4, and D4
pat to RB5, so the function must be called as follows:

. Lcd_Init

The Lcd_Init function is called to set up the interface between the microcontroller and
the LCD screen when the connections are made by default that has just been illustrated. The name of
the port must be specified by passing its address. For example, assuming that the LCD is connected to
PORTB and the previous default connections are used, the function must be called
as a:

Lcd_Init();

. Lcd_Out

The Lcd_Out function displays text at the indicated line and column positions.
the LCD screen. The function must be called with parameters in the following order:
Description

texte

For example, to display the text 'Computer' at line 1 and column 2 of the screen
LCD we should call the function as follows:

Computer

. Lcd_Chr

The function Lcd_Chr displays a character at the indicated line and the column position of the
cursor. The function must be called with the parameters in the following order:
Description

line, column, character

For example, to display the character 'K' at line 2 and column 4 of the LCD screen, we
should call the function of:

Lcd_Chr(2, 4, 'K');
. Lcd_Cmd

The Lcd_Cmd function is used to send a command to the LCD screen. With this
command, we can move the cursor to any line, disable the screen
LCD, make the cursor blink, shift the display, etc. A list of the most commonly used.
LCD orders are given in the table below.

For example, to clear the LCD screen we should call the function as follows:

Lcd_Cmd (Lcd_Clear);
Application exercise

A LCD text controller is connected to a PIC16F877A microcontroller in the


default mode as illustrated below,

Write a program to send the text My Computer to line 1, column 4.


the LCD screen.

You might also like