Introduction to microcontrollers - Irawiki

10 downloads 164 Views 2MB Size Report
Introduction to microcontrollers. Microcontroller architectures. 3 ARM microcontrollers. ARM: Advanced RISC Machines. ARM Cortex-M3. Introduction to STM32 ...
Informatics for industrial applications Lecture 1 - Introduction to microcontrollers Martino Migliavacca [email protected]

October 3, 2011

Introduction

Microcontrollers overview

Outline

1

Introduction Course purposes Course outline

2

Microcontrollers overview Introduction to microcontrollers Microcontroller architectures

3

ARM microcontrollers ARM: Advanced RISC Machines ARM Cortex-M3 Introduction to STM32

ARM microcontrollers

Introduction

Microcontrollers overview

Course purposes Introduction to embedded software development Introduction to microcontrollers Firmware development Hardware debugging

ARM microcontrollers

Introduction

Microcontrollers overview

Course purposes Introduction to embedded software development Introduction to microcontrollers Firmware development Hardware debugging Practical approach Presentation of peripherals during lectures Test on real hardware during lab sessions

ARM microcontrollers

Introduction

Microcontrollers overview

Course purposes Introduction to embedded software development Introduction to microcontrollers Firmware development Hardware debugging Practical approach Presentation of peripherals during lectures Test on real hardware during lab sessions Course goal Enable you to autonomously develop embedded projects

ARM microcontrollers

Introduction

Microcontrollers overview

Course outline Organization The course consists in 12 lectures and 6 lab sessions Lectures: 9 - 10.30 on Wednesday and Thursday One lab session every two lectures Suspension from 26/11 to 10/12

ARM microcontrollers

Introduction

Microcontrollers overview

Course outline Organization The course consists in 12 lectures and 6 lab sessions Lectures: 9 - 10.30 on Wednesday and Thursday One lab session every two lectures Suspension from 26/11 to 10/12 Final project At the and of the course, you will be assigned a project

ARM microcontrollers

Introduction

Microcontrollers overview

ARM microcontrollers

Course outline Organization The course consists in 12 lectures and 6 lab sessions Lectures: 9 - 10.30 on Wednesday and Thursday One lab session every two lectures Suspension from 26/11 to 10/12 Final project At the and of the course, you will be assigned a project Evaluation Evaluation is based on the results of your project: success, code quality, documentation

Introduction

Microcontrollers overview

Course outline - Lectures Lecture 1 - Introduction to microcontrollers Lecture 2 - STM32: getting started, GPIO peripheral Lecture 3 - Peripherals: timers Lecture 4 - Peripherals: ADC and DMA Lecture 5 - Peripherals: USART Lecture 6 - Peripherals: SPI and I2C Lecture 7 - Peripherals: PWM Lecture 8 - Introduction to motor control Lecture 9 - Real time operating systems, ChibiOS/RT Lecture 10 - ChibiOS/RT: Hardware Abstraction Layer Lecture 11 - Fieldbus: the CAN bus Lecture 12 - Project assignment, Q&A

ARM microcontrollers

Introduction

Microcontrollers overview

ARM microcontrollers

Course outline - Lab sessions

Lab 1 - Toolchain and IDE setup, ”Hello world!” Lab 2 - Timers and ADC Lab 3 - USART and SPI Lab 4 - PWM Lab 5 - ChibiOS/RT Lab 6 - Project start

Slides available on course website ( http://irawiki.disco.unimib.it/ -¿ teaching)

Introduction

Microcontrollers overview

Outline

1

Introduction Course purposes Course outline

2

Microcontrollers overview Introduction to microcontrollers Microcontroller architectures

3

ARM microcontrollers ARM: Advanced RISC Machines ARM Cortex-M3 Introduction to STM32

ARM microcontrollers

Introduction

Microcontrollers overview

ARM microcontrollers

What are microcontrollers?

Definition ”A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals”

Introduction

Microcontrollers overview

ARM microcontrollers

What are microcontrollers?

Definition ”A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals” A microcontroller has peripherals, a processor no A microcontroller has an integrated program memory, a processor no A microcontroller usually needs few additional components to run, a processor many Generally speaking, microcontrollers are less aimed at performing heavy processing, more at interfacing with other devices

Introduction

Microcontrollers overview

ARM microcontrollers

Where can you find a microcontroller? Some Wikipedia quotes ”A typical home in a developed country is likely to have only four general-purpose microprocessors but around three dozen microcontrollers” ”A typical mid-range automobile has as many as 30 or more microcontrollers” ”Over four billion 8-bit microcontrollers were sold in 2006”

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC)

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need:

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need: a processor

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need: a processor some memory to store code

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need: a processor some memory to store code some RAM to store data

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need: a processor some memory to store code some RAM to store data one or more analog to digital converters (ADC)

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need: a processor some memory to store code some RAM to store data one or more analog to digital converters (ADC) a SD card controller

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need: a processor some memory to store code some RAM to store data one or more analog to digital converters (ADC) a SD card controller a USB physical layer chip

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (1/2) Example application We want to build a data logger that: acquires analog data records data on a SD card sends data over USB connection timestamps data with a real time clock (RTC) Without a microcontroller, we need: a processor some memory to store code some RAM to store data one or more analog to digital converters (ADC) a SD card controller a USB physical layer chip a real time clock chip

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (2/2) Using a microcontroller, we need:

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (2/2) Using a microcontroller, we need: a microcontroller

ARM microcontrollers

Introduction

Microcontrollers overview

Why should I use a microcontroller? (2/2) Using a microcontroller, we need: a microcontroller

ARM microcontrollers

Introduction

Microcontrollers overview

ARM microcontrollers

Microcontroller architectures: Harvard vs Von Neumann Harvard

Von Neumann

Introduction

Microcontrollers overview

ARM microcontrollers

Microcontroller vendors overview There are many microcontroller manufacturers: Intel developed the 8051 architecture in 1980, still in use Microchip is well known for their PIC, probably the most popular microcontroller Atmel produces the AVR family, that powers Arduino boards ARM based microcontrollers are available from many vendors Parallax produces the Propeller, a multi-core microcontroller Texas Instruments has the MSP430, targeted to ultra-low-power applications Cypress Semiconductors produces the CY8Cxxxxx family of PSoC (programmable system on chip) Analog Devices sells precision analog ADuC microcontrollers Rabbit, Dallas, Freescale, Lattice, Infineon, ST Mircoelectronics, Toshiba, Zilog...

Introduction

Microcontrollers overview

Intel 8051 architecture - 1980

ARM microcontrollers

Introduction

STM32F2xx - 2011

Microcontrollers overview

ARM microcontrollers

Introduction

Microcontrollers overview

STM32F2xx - 2011 ...

ARM microcontrollers

Introduction

Microcontrollers overview

Outline

1

Introduction Course purposes Course outline

2

Microcontrollers overview Introduction to microcontrollers Microcontroller architectures

3

ARM microcontrollers ARM: Advanced RISC Machines ARM Cortex-M3 Introduction to STM32

ARM microcontrollers

Introduction

Microcontrollers overview

ARM - Advanced RISC Machines Founded in 1990 by Acorn, Apple and VLSI Headquarters in Cambridge, United Kingdom ARM is not a manufacturer, it licenses intellectual property to manufacturers

ARM microcontrollers

Introduction

Microcontrollers overview

ARM - Advanced RISC Machines Founded in 1990 by Acorn, Apple and VLSI Headquarters in Cambridge, United Kingdom ARM is not a manufacturer, it licenses intellectual property to manufacturers Alcatel-Lucent, Apple Inc., Atmel, Broadcom, Cirrus Logic, Digital Equipment Corporation, Freescale, DEC, LG, Marvell, Microsoft, NEC, Nintendo, Nvidia, Sony, NXP, Oki, ON Semiconductor, Qualcomm, Samsung, Sharp, STMicroelectronics, Texas Instruments, VLSI Technology, Yamaha and more

ARM microcontrollers

Introduction

Microcontrollers overview

ARM - Advanced RISC Machines Founded in 1990 by Acorn, Apple and VLSI Headquarters in Cambridge, United Kingdom ARM is not a manufacturer, it licenses intellectual property to manufacturers Alcatel-Lucent, Apple Inc., Atmel, Broadcom, Cirrus Logic, Digital Equipment Corporation, Freescale, DEC, LG, Marvell, Microsoft, NEC, Nintendo, Nvidia, Sony, NXP, Oki, ON Semiconductor, Qualcomm, Samsung, Sharp, STMicroelectronics, Texas Instruments, VLSI Technology, Yamaha and more

In 2010, over 95% of the smartphones sold used an ARM processor As of 2009, ARM processors account for approximately 90% of all embedded 32-bit RISC processors

ARM microcontrollers

Introduction

ARM cores

Microcontrollers overview

ARM microcontrollers

Introduction

Microcontrollers overview

ARM Cortex embedded processors

ARM microcontrollers

Introduction

Microcontrollers overview

ARM Cortex embedded processors

ARM microcontrollers

Introduction

Microcontrollers overview

ARM Cortex-M3

ARMv7 32 bit core Advanced 3-stage pipeline core based on Harvard architecture Thumb-2 instruction set 1.25 DMIPS/MHz 8 to 256 priority levels Up to 240 Wake-up Interrupts Nested Vectored Interrupt Controller JTAG or 2-pin Serial Wire Debug (SWD)

ARM microcontrollers

Introduction

Microcontrollers overview

ARM microcontrollers

Cortex-M3 architecture: advantages (1/3) Instruction width ARM Cortex-M processor based microcontrollers use 32-bit instructions on a 32-bit core. The PIC18 and PIC16 instruction sizes are 16-bit and 14-bit respectively, on 8-bit cores.

Introduction

Microcontrollers overview

ARM microcontrollers

Cortex-M3 architecture: advantages (2/3) Instruction efficiency There are many circumstances where a single Thumb instruction equates to several 8/16-bit microcontroller instructions

Introduction

Microcontrollers overview

Cortex-M3 architecture: advantages (3/3) Enhanced Instructions Single-cycle (32x32) multiply Hardware divide (2-12 cycles)

ARM microcontrollers

Introduction

Microcontrollers overview

Cortex-M3 architecture: NVIC Complete response to interrupts in hardware

ARM microcontrollers

Introduction

Microcontrollers overview

Cortex-M3 architecture: NVIC Complete response to interrupts in hardware Tail chaining in the NVIC

ARM microcontrollers

Introduction

Microcontrollers overview

ARM microcontrollers

Cortex-M3 architecture: NVIC Complete response to interrupts in hardware Tail chaining in the NVIC

Response of the NVIC to late arrival of higher priority interrupts

Introduction

Microcontrollers overview

The STM32 microcontroller by ST (1/2)

STM32 F1 series: mainstream MCUs ARM Cortex-M3 core More than 90 devices Frequencies from 24Mhz to 72Mhz Up to 96Kb RAM size Up to 1024Kb Flash size From 36 to 144 pins (26 to 112 I/Os) CMSIS compliant Low-power modes Price starting at 2$

ARM microcontrollers

Introduction

Microcontrollers overview

The STM32 microcontroller by ST (2/2)

ARM microcontrollers

Introduction

Microcontrollers overview

Where to find information (1/2) The datasheet is the document that describes an electronic component Almost every component has a datasheet, that reports: the description of the component the pinout of the component electrical specifications (max/min voltage supply, current drawn, ...) performance details (frequency response, noise, ...) thermal characteristics mechanical characteristics, technical drawing and footprint generally, a reference design

ARM microcontrollers

Introduction

Microcontrollers overview

Where to find information (2/2) The reference manual gives extensive documentation of complex components, like: extensive description of the device modes of operation configuration details registers map Application notes are additional documents about: common applications example configurations complete systems using the specific components demo boards

ARM microcontrollers

References http://en.wikipedia.org/wiki/Microcontroller http://en.wikipedia.org/wiki/8051 http://en.wikipedia.org/wiki/ARM Holdings http://en.wikipedia.org/wiki/ARM architecture http://www.arm.com/products/processors/ http://www.arm.com/products/processors/cortex-m/cortex-m3.php http://www.st.com/internet/mcu/class/1734.jsp STM32F103xC, STM32F103xD, STM32F103xE datasheet (Doc ID 13902) STM32F10xxx Reference Manual (RM0008 - Doc ID 14611) http://www.sxlist.com/techref/microchip/math/32bmath-ph.htm

Suggest Documents