SlideShare a Scribd company logo
1 of 14
Download to read offline
Introduction to Microcontrollers
Corrado Santoro
ARSLAB - Autonomous and Robotic Systems Laboratory
Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy
santoro@dmi.unict.it
L.A.P. 1 Course
Corrado Santoro Introduction to Microcontrollers
What is a “Microcontroller”?
A Microcontroller (MCU) is an integrated circuit including all
parts of complete computer.
In includes:
CPU
Built-in oscillator for clock source
Flash memory (in the order of KBytes/MBytes), to hold
the program
RAM, in the order of KBytes/MBytes
Several I/O peripherals for both generic and specific
purposes
In its PINs, a microcontroller does not provides the BUS (as in
normal CPUs) but the I/O peripherals.
Corrado Santoro Introduction to Microcontrollers
What is a “Microcontroller”?
Corrado Santoro Introduction to Microcontrollers
What are the typical peripherals?
Digital (1-bit) lines
Analog lines
Analog-to-Digital (ADC)
Digital-to-Analog (DAC)
Timers
Special digital lines (Pulse-Width-Modulation);
Communication interfaces for other devices and/or
sensors/actuators:
USB
UART (serial port)
SPI (Serial Peripheral Interface)
I2C (I-square-C)
CAN (Controller Area Network)
Ethernet
...
Corrado Santoro Introduction to Microcontrollers
Where do microcontrollers are employed?
Special-purpose applications/equipments, such as:
Measurement equipments;
Cars (i.e. automotive industry, engine control, driver
assistance);
Household Appliances (TV sets, set-top-boxes, DVD,
washing machines, microwave ovens, etc.);
Previous-generation cellphones and smartphones;
Industrial automation, robotics;
...
Corrado Santoro Introduction to Microcontrollers
How do microcontrollers are programmed?
Generally, they run the software in bare metal, i.e. without
an operating system.
A specific term exists for MCU software: firmware
Usually they are programmed in C or assembly through a
development tool running in a host computer which
includes:
A compiler
A hardware tool to transfer the code into the flash memory
An in-circuit debugger (optional)
When the firmware is written in C, the MCU, at power-up,
runs the program directly from the main() function.
Corrado Santoro Introduction to Microcontrollers
Microcontrollers: manufacturers and families
There are many manufacturers of microcontrollers:
Microchip
Atmel
Freescale
STMicroelectronics
Intel
...
A specific microcontroller (the specific chip) is identified by:
The core, that is the CPU: 8-bit, 16-bit, 32-bit, etc.
The core usually denotes also the family
The amount of flash memory and RAM
The peripherals which are included in the chip
Corrado Santoro Introduction to Microcontrollers
The MCU we will use!
We will use the MCU PIC18F25K22 by Microchip.
PIC18 denotes the Microchip family of 8-bit advanced MCU
F means that the MCU has a flash memory
25K22 is a code that identifies the amount of memory and
the embedded peripherals
All MCUs of the same family are programmed in the same way.
Corrado Santoro Introduction to Microcontrollers
The PIC18F25K22
The figure shows the “pinout” of the PIC18F25K22 microcontroller:
VDD, VSS. These are the pins to power-up the MCU (the voltage used
is 5V or 3.3V)
MCLR. The Master Clear (RESET) pin; connecting this pin to ground
(VSS, 0V) causes a CPU reset.
All other pins are relative to I/O peripherals.
Corrado Santoro Introduction to Microcontrollers
How can I use/program a MCU?
Using MCU implies to use its peripherals
Thus, we must learn how to program in C the MCU
peripherals
A certain region of the system memory is reserved for
peripherals
In this region, each memory location has a specific
meaning
These memory locations are called Special Function
Registers (SFRs)
Writing a data into a SFR implies to program the
behaviour of a specific peripheral
Corrado Santoro Introduction to Microcontrollers
Some SFR of the PIC18F25K22
The meaning of each SFR is reported in the programmer’s
manual of the specific MCU
Corrado Santoro Introduction to Microcontrollers
How can I access SFR?
Using C pointers!! But ...
The Microchip C compiler exports a global variable for
each SFR, whose name matches the name of the SFR.
Therefore, a SFR can be accessed, in C program, by using
the relevant variable directly.
Corrado Santoro Introduction to Microcontrollers
Resources
Microchip MPLABX IDE:
http://www.microchip.com/mplabx
Microchip C compiler for 8-bit MCU, XC8:
http://www.microchip.com/mplabx
A terminal emulator program, such as:
minicom or cutecom, for Linux;
ZOC Terminal, for Win and MacOS.
The “Data Sheet” of the MCU PIC18F25K22:
http://www.microchip.com/
Corrado Santoro Introduction to Microcontrollers
Introduction to Microcontrollers
Corrado Santoro
ARSLAB - Autonomous and Robotic Systems Laboratory
Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy
santoro@dmi.unict.it
L.A.P. 1 Course
Corrado Santoro Introduction to Microcontrollers

More Related Content

What's hot

PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mappingOsaMa Hasan
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollersMAIYO JOSPHAT
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller Raghav Shetty
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC MicrocontrollerDivya Bansal
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontrollerSiva Kumar
 
PIC microcontroller review
PIC microcontroller reviewPIC microcontroller review
PIC microcontroller reviewMohsen Sarakbi
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC MicrocontrollersPremier Farnell
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
AVR Micro controller Interfacing
AVR Micro controller Interfacing AVR Micro controller Interfacing
AVR Micro controller Interfacing Raghav Shetty
 
GPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cGPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cZakaria Gomaa
 
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLERGSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLERMd. Moktarul Islam
 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)Sahil Gupta
 
Microchip's PIC Micro Controller
Microchip's PIC Micro ControllerMicrochip's PIC Micro Controller
Microchip's PIC Micro ControllerMidhu S V Unnithan
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manualArun Shan
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller Gaurav Verma
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR FundamentalsVinit Vyas
 

What's hot (19)

PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mapping
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollers
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 
Pic16f84
Pic16f84Pic16f84
Pic16f84
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
 
PIC microcontroller review
PIC microcontroller reviewPIC microcontroller review
PIC microcontroller review
 
ATmega 16
ATmega 16ATmega 16
ATmega 16
 
Pic full note
Pic full notePic full note
Pic full note
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC Microcontrollers
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
AVR Micro controller Interfacing
AVR Micro controller Interfacing AVR Micro controller Interfacing
AVR Micro controller Interfacing
 
GPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cGPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-c
 
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLERGSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)
 
Microchip's PIC Micro Controller
Microchip's PIC Micro ControllerMicrochip's PIC Micro Controller
Microchip's PIC Micro Controller
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manual
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR Fundamentals
 

Viewers also liked

Introduction of microcontroller
Introduction of microcontrollerIntroduction of microcontroller
Introduction of microcontrollerEngineer Maze
 
Integrated Circuits
Integrated CircuitsIntegrated Circuits
Integrated CircuitsANAND G
 
Integrated circuits
Integrated circuitsIntegrated circuits
Integrated circuitsNaveen Sihag
 
Know About Different Types of Integrated Circuits
Know About Different Types of Integrated CircuitsKnow About Different Types of Integrated Circuits
Know About Different Types of Integrated Circuitselprocus
 
Integrated circuits
Integrated circuitsIntegrated circuits
Integrated circuitsdhawal mehta
 
Integrated circuit
Integrated circuitIntegrated circuit
Integrated circuitJessa Arnado
 
Computer Integrated Manufacturing
Computer Integrated Manufacturing  Computer Integrated Manufacturing
Computer Integrated Manufacturing suraj_21
 

Viewers also liked (8)

Introduction of microcontroller
Introduction of microcontrollerIntroduction of microcontroller
Introduction of microcontroller
 
Integrated Circuits
Integrated CircuitsIntegrated Circuits
Integrated Circuits
 
Introduction to Microcontrollers
Introduction to MicrocontrollersIntroduction to Microcontrollers
Introduction to Microcontrollers
 
Integrated circuits
Integrated circuitsIntegrated circuits
Integrated circuits
 
Know About Different Types of Integrated Circuits
Know About Different Types of Integrated CircuitsKnow About Different Types of Integrated Circuits
Know About Different Types of Integrated Circuits
 
Integrated circuits
Integrated circuitsIntegrated circuits
Integrated circuits
 
Integrated circuit
Integrated circuitIntegrated circuit
Integrated circuit
 
Computer Integrated Manufacturing
Computer Integrated Manufacturing  Computer Integrated Manufacturing
Computer Integrated Manufacturing
 

Similar to Introduction to microcontrollers

Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to MicrocontrollerNikhil Sharma
 
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdfIntroduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdfaienterpresses
 
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdfIntroduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdfaienterpresses
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerRup Chowdhury
 
microprocessor
microprocessormicroprocessor
microprocessorillpa
 
Difference Between Microprocessors and Microcontrollers
Difference Between Microprocessors and MicrocontrollersDifference Between Microprocessors and Microcontrollers
Difference Between Microprocessors and Microcontrollerselprocus
 
Lecture 5-Embedde.pdf
Lecture 5-Embedde.pdfLecture 5-Embedde.pdf
Lecture 5-Embedde.pdfBlackHunter13
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollersnehapvs
 
Introduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIntroduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIslam Samir
 
Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 vijaydeepakg
 
An introduction to digital signal processors 1
An introduction to digital signal processors 1An introduction to digital signal processors 1
An introduction to digital signal processors 1Hossam Hassan
 
INTRODUCTION TO MICRCONTROLLER
INTRODUCTION TO MICRCONTROLLERINTRODUCTION TO MICRCONTROLLER
INTRODUCTION TO MICRCONTROLLERkhalil zeineddine
 
M.sc I-sem-8086 notes
M.sc  I-sem-8086 notesM.sc  I-sem-8086 notes
M.sc I-sem-8086 notesDr.YNM
 
M.sc I-sem-8086 notes
M.sc  I-sem-8086 notesM.sc  I-sem-8086 notes
M.sc I-sem-8086 notesDr.YNM
 
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxMeghdeepSingh
 
Microcontoller and Embedded System
Microcontoller and Embedded SystemMicrocontoller and Embedded System
Microcontoller and Embedded SystemKaran Thakkar
 

Similar to Introduction to microcontrollers (20)

Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdfIntroduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
 
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdfIntroduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdf
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontroller
 
microprocessor
microprocessormicroprocessor
microprocessor
 
Difference Between Microprocessors and Microcontrollers
Difference Between Microprocessors and MicrocontrollersDifference Between Microprocessors and Microcontrollers
Difference Between Microprocessors and Microcontrollers
 
Lecture 5-Embedde.pdf
Lecture 5-Embedde.pdfLecture 5-Embedde.pdf
Lecture 5-Embedde.pdf
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Arjit intro
Arjit introArjit intro
Arjit intro
 
Introduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIntroduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and Microcontrollers
 
Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 Sudhir tms 320 f 2812
Sudhir tms 320 f 2812
 
An introduction to digital signal processors 1
An introduction to digital signal processors 1An introduction to digital signal processors 1
An introduction to digital signal processors 1
 
3.TechieNest microcontrollers
3.TechieNest  microcontrollers3.TechieNest  microcontrollers
3.TechieNest microcontrollers
 
INTRODUCTION TO MICRCONTROLLER
INTRODUCTION TO MICRCONTROLLERINTRODUCTION TO MICRCONTROLLER
INTRODUCTION TO MICRCONTROLLER
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
M.sc I-sem-8086 notes
M.sc  I-sem-8086 notesM.sc  I-sem-8086 notes
M.sc I-sem-8086 notes
 
M.sc I-sem-8086 notes
M.sc  I-sem-8086 notesM.sc  I-sem-8086 notes
M.sc I-sem-8086 notes
 
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
 
Microcontoller and Embedded System
Microcontoller and Embedded SystemMicrocontoller and Embedded System
Microcontoller and Embedded System
 
Iot Workshop NITT 2015
Iot Workshop NITT 2015Iot Workshop NITT 2015
Iot Workshop NITT 2015
 

More from Corrado Santoro

Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...Corrado Santoro
 
Pulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUsPulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUsCorrado Santoro
 
Using Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUsUsing Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUsCorrado Santoro
 
Handling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsHandling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsCorrado Santoro
 
Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015Corrado Santoro
 
Presentation @ WOA 2015
Presentation @ WOA 2015 Presentation @ WOA 2015
Presentation @ WOA 2015 Corrado Santoro
 
Using Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR LibrariesUsing Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR LibrariesCorrado Santoro
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scriptingCorrado Santoro
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converterCorrado Santoro
 
Exercises with timers and UART
Exercises with timers and UARTExercises with timers and UART
Exercises with timers and UARTCorrado Santoro
 
Handling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsHandling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsCorrado Santoro
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersCorrado Santoro
 
Programming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerProgramming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerCorrado Santoro
 
How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...Corrado Santoro
 

More from Corrado Santoro (20)

Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
 
Using Timer1 and CCP
Using Timer1 and CCPUsing Timer1 and CCP
Using Timer1 and CCP
 
Pulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUsPulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUs
 
Using Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUsUsing Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUs
 
Handling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsHandling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUs
 
Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015
 
Presentation @ WOA 2015
Presentation @ WOA 2015 Presentation @ WOA 2015
Presentation @ WOA 2015
 
Soc
SocSoc
Soc
 
Using Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR LibrariesUsing Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR Libraries
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Pillole di C++
Pillole di C++Pillole di C++
Pillole di C++
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
Exercises with timers and UART
Exercises with timers and UARTExercises with timers and UART
Exercises with timers and UART
 
UART MCU
UART MCUUART MCU
UART MCU
 
Handling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsHandling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUs
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F Microcontrollers
 
Programming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerProgramming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontroller
 
How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...
 

Introduction to microcontrollers

  • 1. Introduction to Microcontrollers Corrado Santoro ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy santoro@dmi.unict.it L.A.P. 1 Course Corrado Santoro Introduction to Microcontrollers
  • 2. What is a “Microcontroller”? A Microcontroller (MCU) is an integrated circuit including all parts of complete computer. In includes: CPU Built-in oscillator for clock source Flash memory (in the order of KBytes/MBytes), to hold the program RAM, in the order of KBytes/MBytes Several I/O peripherals for both generic and specific purposes In its PINs, a microcontroller does not provides the BUS (as in normal CPUs) but the I/O peripherals. Corrado Santoro Introduction to Microcontrollers
  • 3. What is a “Microcontroller”? Corrado Santoro Introduction to Microcontrollers
  • 4. What are the typical peripherals? Digital (1-bit) lines Analog lines Analog-to-Digital (ADC) Digital-to-Analog (DAC) Timers Special digital lines (Pulse-Width-Modulation); Communication interfaces for other devices and/or sensors/actuators: USB UART (serial port) SPI (Serial Peripheral Interface) I2C (I-square-C) CAN (Controller Area Network) Ethernet ... Corrado Santoro Introduction to Microcontrollers
  • 5. Where do microcontrollers are employed? Special-purpose applications/equipments, such as: Measurement equipments; Cars (i.e. automotive industry, engine control, driver assistance); Household Appliances (TV sets, set-top-boxes, DVD, washing machines, microwave ovens, etc.); Previous-generation cellphones and smartphones; Industrial automation, robotics; ... Corrado Santoro Introduction to Microcontrollers
  • 6. How do microcontrollers are programmed? Generally, they run the software in bare metal, i.e. without an operating system. A specific term exists for MCU software: firmware Usually they are programmed in C or assembly through a development tool running in a host computer which includes: A compiler A hardware tool to transfer the code into the flash memory An in-circuit debugger (optional) When the firmware is written in C, the MCU, at power-up, runs the program directly from the main() function. Corrado Santoro Introduction to Microcontrollers
  • 7. Microcontrollers: manufacturers and families There are many manufacturers of microcontrollers: Microchip Atmel Freescale STMicroelectronics Intel ... A specific microcontroller (the specific chip) is identified by: The core, that is the CPU: 8-bit, 16-bit, 32-bit, etc. The core usually denotes also the family The amount of flash memory and RAM The peripherals which are included in the chip Corrado Santoro Introduction to Microcontrollers
  • 8. The MCU we will use! We will use the MCU PIC18F25K22 by Microchip. PIC18 denotes the Microchip family of 8-bit advanced MCU F means that the MCU has a flash memory 25K22 is a code that identifies the amount of memory and the embedded peripherals All MCUs of the same family are programmed in the same way. Corrado Santoro Introduction to Microcontrollers
  • 9. The PIC18F25K22 The figure shows the “pinout” of the PIC18F25K22 microcontroller: VDD, VSS. These are the pins to power-up the MCU (the voltage used is 5V or 3.3V) MCLR. The Master Clear (RESET) pin; connecting this pin to ground (VSS, 0V) causes a CPU reset. All other pins are relative to I/O peripherals. Corrado Santoro Introduction to Microcontrollers
  • 10. How can I use/program a MCU? Using MCU implies to use its peripherals Thus, we must learn how to program in C the MCU peripherals A certain region of the system memory is reserved for peripherals In this region, each memory location has a specific meaning These memory locations are called Special Function Registers (SFRs) Writing a data into a SFR implies to program the behaviour of a specific peripheral Corrado Santoro Introduction to Microcontrollers
  • 11. Some SFR of the PIC18F25K22 The meaning of each SFR is reported in the programmer’s manual of the specific MCU Corrado Santoro Introduction to Microcontrollers
  • 12. How can I access SFR? Using C pointers!! But ... The Microchip C compiler exports a global variable for each SFR, whose name matches the name of the SFR. Therefore, a SFR can be accessed, in C program, by using the relevant variable directly. Corrado Santoro Introduction to Microcontrollers
  • 13. Resources Microchip MPLABX IDE: http://www.microchip.com/mplabx Microchip C compiler for 8-bit MCU, XC8: http://www.microchip.com/mplabx A terminal emulator program, such as: minicom or cutecom, for Linux; ZOC Terminal, for Win and MacOS. The “Data Sheet” of the MCU PIC18F25K22: http://www.microchip.com/ Corrado Santoro Introduction to Microcontrollers
  • 14. Introduction to Microcontrollers Corrado Santoro ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy santoro@dmi.unict.it L.A.P. 1 Course Corrado Santoro Introduction to Microcontrollers