Embedded Programming with ARM Cortex-M3 Basic Experiments 1

Similar documents
Introduction to Embedded Programming with ARM Cortex-M3

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

STM32 Cortex-M3 STM32F STM32L STM32W

Hello, and welcome to this presentation of the STM32L4 power controller. The STM32L4 s power management functions and all power modes will also be

[MG2420] MCU Module Datasheet. (No. ADS0705) V1.0

STM32L4 System operating modes

AN2585 Application note

Hello, and welcome to this presentation of the STM32F7 System Configuration Controller.

AK-STM32-ETH Development Board

STM8L and STM32 L1 series. Ultra-low-power platform

Hello, and welcome to this presentation of the STM32 Reset and Clock Controller.

BLE MODULE SPECIFICATIONS

AN2606 Application note

AN5123 Application note

Getting Started With the Stellaris EK-LM4F120XL LaunchPad Workshop. Version 1.05

Designing with STM32F2x & STM32F4

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

STM32F4 Labs. T.O.M.A.S Technically Oriented Microcontroller Application Services V1.07

AT-501 Cortex-A5 System On Module Product Brief

Product Technical Brief S3C2412 Rev 2.2, Apr. 2006

2-Oct-13. the world s most energy friendly microcontrollers and radios

Arduino Uno R3 INTRODUCTION

AN4749 Application note

AN4515 Application note

Microcontroller. BV523 32bit Microcontroller. Product specification. Jun 2011 V0.a. ByVac Page 1 of 8

Introducing STM32 L0x Series. April

STM32G0 MCU Series Efficiency at its Best

Product Specification

BT-22 Product Specification

XNUCLEO-F030R8, Improved STM32 NUCLEO Board

Cookie User Manual. For NuMicro Edition 1.0. Rev. 1.0 Release: forum.coocox.org.

STM32SnippetsL0. STM32L0xx Snippets firmware package. Features. Description

FiO Lite Datasheet FEATURES SAMPLE APPLICATIONS. FiO Lite

ARDUINO YÚN MINI Code: A000108

STM32 F0 Value Line. Entry-level MCUs

AM18X5. 1. Introduction. 2. System Power Control Applications. Application Note. AM18X5 Family System Power Management

8. Power Management and Sleep Modes

AN4311 Application note

Product Technical Brief S3C2413 Rev 2.2, Apr. 2006

STG - STM32 + FreeRTOS + LwIP/EmWin

The course provides all necessary theoretical and practical know-how for start developing platforms based on STM32L4 family.

New STM32WB Series MCU with Built-in BLE 5 and IEEE

RN-171-EK Evaluation Board

Unlocking the Potential of Your Microcontroller

Product Technical Brief S3C2440X Series Rev 2.0, Oct. 2003

Exceptions and Interrupts ARM Cortex M3

Wireless Sensor Networks. FireFly 2.2 Datasheet

ARDUINO M0 PRO Code: A000111

Introduction to ARM LPC2148 Microcontroller

ARDUINO MEGA INTRODUCTION

Building Interactive Devices and Objects. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

Realtek Ameba-1 Power Modes

Release Notes for ADuCM302x EZ-KIT Lite Board Support Package 1.0.3

STM32 MICROCONTROLLER

Wireless-Tag WT51822-S1

AN4696 Application note

STM32F7 series ARM Cortex -M7 powered Releasing your creativity

User Manual Rev. 0. Freescale Semiconductor Inc. FRDMKL02ZUM

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite.

STM bit ARM Cortex MCUs STM32F030 Series

Product Brief. Model: TLM922S-P01A. Ver.1.0

Interconnects, Memory, GPIO

AIM: To create a project for implement a wireless communication protocol on an embedded system- ZigBee.

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

CN310 Microprocessor Systems Design

Typical Applications: GHz Bluetooth low energy systems - Proprietary 2.4 GHz systems - Sports and leisure equipment - Mobile phone accessories,

Product Specification

Hello and welcome to this Renesas Interactive module that covers the Independent watchdog timer found on RX MCUs.

nblue TM BR-MUSB-LE4.0-S2A (CC2540)

User Manual. cmt-svr Startup Guide

Ultra Low Power Microcontroller - Design Criteria - June 2017

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

New STM32WB Series MCU with built-in Bluetooth 5 and IEEE

XMEGA Series Of AVR Processor. Presented by: Manisha Biyani ( ) Shashank Bolia (

Kinetis K70 System-On-Module (SOM) Baseboard Hardware Architecture

MICROPROCESSOR BASED SYSTEM DESIGN

BLE121LR Bluetooth Smart Long Range Module 5/12/2014 1

AVR Microcontrollers Architecture

ARDUINO INDUSTRIAL 1 01 Code: A000126

ARDUINO LEONARDO ETH Code: A000022

FRDM-KE02Z User s Manual

Remote Keyless Entry In a Body Controller Unit Application

User Manual For CP-JR ARM7 USB-LPC2148 / EXP

STM32F429 Overview. Steve Miller STMicroelectronics, MMS Applications Team October 26 th 2015

Release Notes for ADuCM302x EZ-KIT Lite Board Support Package 1.0.2

Hands on Experience with AVR32

STM32L4R9I-EVAL. Evaluation board with STM32L4R9AI MCU. Features

Advanced Embedded Systems

Freescale Semiconductor Inc. Microcontroller Solutions Group. FRDM-KL46Z User s Manual FRDM-KL46Z-UM Rev. 1.0

Machine TV Interface. mtv-100. Memory Processor. I/O Port RTC. Power. Specification. Certificate Software

Let s first take a look at power consumption and its relationship to voltage and frequency. The equation for power consumption of the MCU as it

Xynergy It really makes the difference!

ARDUINO UNO REV3 Code: A000066

ARDUINO YÚN Code: A000008

JetBox 9300/9310 User Manual. Hardware

ARM Cortex core microcontrollers 12 th Energy efficient operation

Clock and Fuses. Prof. Prabhat Ranjan Dhirubhai Ambani Institute of Information and Communication Technology, Gandhinagar

STM32L4+ MCU series Excellence in ultra-low-power with more performance

Hello, and welcome to this presentation of the STM32 Low Power Universal Asynchronous Receiver/Transmitter interface. It covers the main features of

Transcription:

Embedded Programming with ARM Cortex-M3 Basic Experiments 1 Alan Xiao, Ph.D Handheld Scientific, Inc. qiwei@handheldsci.com

Today s Topics Basics (with the Discovery board): 1. General Input/Output (GPIO) 2. USART (serial) 3. SysTick 4. Unique ID 5. EXTI - External Interrupt 6. Real-time Clock/Calendar 7. Timer/PWM 8. Watchdogs (independent/window) 9. CRC (Cyclic Redundancy Check) 10. PVD (Programmable Voltage Detector) 11. Sleep/Stop/Standby Modes Advanced (with the STM3210C or similar board): 1. I2C/EEPROM 2. ADC 3. RS-485 4. LCD display/touch Screen 5. SPI and Sensors 6. I2S Audio 7. Wireless (with external 315M and 2.4G modules) 8. USB Mouse and Keyboard 9. USB DFU (device firmware upgrade) 10. USB HID 11. USB Virtual COM Port 12. USB PCM Audio 13. Ethernet Telnet 14. Ethernet HTTP (i.e., control hardware via a web browser!) 15. Ethernet TFTP 16. USB Host 17. Running an OS on Cortex-M3 Copyright 2011 (c), Alan Xiao 2

Getting USART/Serial Port to work It is essential to get the USART to work. This is the conduit to the outside world. Most code examples will use the USART to display the results/messages. See code example on the intro session on how to get USART to work. Copyright 2011 (c), Alan Xiao 3

TTL/RS232 Level Consideration The USART IO in Discovery board is TTL level. To communicate with a PC: If you would like to use the RS-232 serial port (9 or 25pin D connector) on your PC (assuming there is one), you need a TTL to RS-232 level convertor such as a UT232R-200 from FTDI or a MAX3232 chip. If you would like to use an USB port, you need an USB to USART bridge such as an UB232R module from FTDI. In either case, only 3 wires are needed: Ground, RX<->TX, TX<-> RX. Copyright 2011 (c), Alan Xiao 4

Discovery and FTDI UB232R on a Bread Board Copyright 2011 (c), Alan Xiao 5

STM32 Memory Map 32-bit address: 4G addressable space. Everything has an address: registers, Flash, SRAM, etc. Flash starts at 0x08000000. SRAM starts at 0x20000000. That is probably all we need to know at the moment. Copyright 2011 (c), Alan Xiao 6

STM32 Boot Modes STM32 can boot from one of the following: User Flash Memory, System Memory and Embedded SRAM. This is controlled by two pins: System memory has a built-in serial boot loader for burning firmware into the chip without restoring to JTAG/SWD port. Booting and running program from RAM is faster. On the Discovery, both BOOT1 and BOOT2 are fixed to 0 so it only boots from user flash memory (although you can remove the soldered connectors to change that). Copyright 2011 (c), Alan Xiao 7

IAR Linker Memory Setting Copyright 2011 (c), Alan Xiao 8

SysTick Timer 24-bit countdown timer. It generates an interrupt when reaching zero and reloads value. The Library greatly simplifies its use. Simply call the following function: SysTick_Config(number_of_clock_cycles_in_a_period) Parameter can t exceeds 2^24 (about 16M). So for a 24M clock, the longest period is 16/24=667ms. If you need more control, mess up with the registers directly: Control & Status Register (enable, clock source, etc.). Reload value Current value Code example: simply print out a message in interrupt. Copyright 2011 (c), Alan Xiao 9

Unique Device ID Each STM32 device has a 96-bit (12 bytes) unique ID (guaranteed to be unique among the device family). Useful for: product serial number Security key for encryptions, for instance. To activate secure boot processer, etc. ID can be read as byte, half-word or word. Located in 0x1FFFF7E8 ~ 0x1FFFF7F3 memory location. See code example how to get it. Copyright 2011 (c), Alan Xiao 10

Interrupt Priority Two priorities: Preemptive Priority and Sub-priority. Lower number has higher priority. STM32 uses 4 bits in a register to specify the two priority settings. To be more flexible, it allows to specify the number of bits in that 4 bits for preemptive priority (the rest is for sub-priority). Group 0: 0 bit for preemptive priority. 4 bits for sub-priority. Group 1: 1 bit for preemptive priority. 3 bits for sub-priority. Group 4: 4 bits for preemptive priority. No bits for subpriority. Use NVIC_PriorityGroupConfig(NVIC_PriorityGroup_N) (n=0, 1, 2, 3 or 4) for the setting. Copyright 2011 (c), Alan Xiao 11

External Interrupts (EXTI) There are 16 EXTI lines: PA0, PB0,, PF0 use the same line EXTI_Line0 PA1, PB1,, PF1 use the same line EXTI_Line1 PA15, PB15,, PF15 use the same line EXTI_Line15 Use GPIO_EXTILineConfig() to tell the MCU which pin is being used. Copyright 2011 (c), Alan Xiao 12

External Interrupts (EXTI) EXTI Line 0 4 have their own dedicate interrupt source. EXTI Line 5-9 share one interrupt source, so do EXTI Line 10-15. Handler Names: EXTI0_IRQHandler();, EXTI4_IRQHandler() EXTI9_5_IRQHandler(); EXTI15_10_IRQHandler() To set up EXTI: Setup GPIO. Turn on AFIO (alternate function) Setup EXTI Source Setup EXTI Line Setup Interrupt Populate Interrupt handler Much better than polling. No debouncing is necessary! Copyright 2011 (c), Alan Xiao 13

External Interrupts (EXTI) For EXTI line 5-15, in the interrupt handler, need to have some code to determine which line generated the interrupt. Something like this: void EXTI9_5_IRQHandler(void) { if (EXTI_GetITStatus(EXTI_Line5)!= RESET) { EXTI_ClearITPendingBit(EXTI_Line5); } else if (EXTI_GetITStatus(EXTI_Line6)!= RESET) { EXTI_ClearITPendingBit(EXTI_Line6); } } Copyright 2011 (c), Alan Xiao 14

Power Modes Run Normal operation. Sleep Core stopped. Peripherals kept running Stop all clocks are stopped Standby all powered off except backup domain (backup registers and RTC). Copyright 2011 (c), Alan Xiao 15

Power Saving Modes Copyright 2011 (c), Alan Xiao 16

Power Saving Modes Power consumption in different power modes (very rough numbers): Normal (run): from a few ma to 50 ma (depending largely on the peripherals and clock speed) Sleep: from a few ma to 30mA Stop: 20 200uA Standby: a few ua Backup domain and RTC (on VBAT pin): 2uA. A good power-saving strategy is to put the MCU in stop/standby mode and wake it up periodically using RTC or external trigger. Copyright 2011 (c), Alan Xiao 17

Power Saving Modes Use the following Library calls to enter different power modes: PWR_EnterSTOPMode(PWR_Regulator_LowPow er, PWR_STOPEntry_WFE); PWR_EnterSTANDBYMode(); Stop mode: external interrupt can wake it up. Standby mode: only the wakeup pin (and reset) can wake it up. See code example. Copyright 2011 (c), Alan Xiao 18

Real-time Clock (RTC) Backup domain: RTC and 42 backup registers. Their power is provided by a dedicated pin (VBAT) which is usually connected to a battery (not in the Discovery board though). The backup domain is not affected by system reset (i.e., the RTC keeps running even during reset. The backup register values also survive resets). The RTC is driven by a dedicate clock, either internally or more often, an external 32.768K crystal. After reset, the access to the backup domain is prohibited until it is explicitly enabled, to prevent accidental writing. RTC can generate second interrupts or alarm interrupts. Copyright 2011 (c), Alan Xiao 19

What s Next Basics (with the Discovery board): 1. General Input/Output (GPIO) 2. USART (serial) 3. SysTick 4. Unique ID 5. EXTI - External Interrupt 6. Real-time Clock/Calendar 7. Timer/PWM 8. Watchdogs (independent/window) 9. CRC (Cyclic Redundancy Check) 10. PVD (Programmable Voltage Detector) 11. Sleep/Stop/Standby Modes Advanced (with the STM3210C or similar board): 1. I2C/EEPROM 2. ADC 3. RS-485 4. LCD display/touch Screen 5. SPI and Sensors 6. I2S Audio 7. Wireless (with external 315M and 2.4G modules) 8. USB Mouse and Keyboard 9. USB DFU (device firmware upgrade) 10. USB HID 11. USB Virtual COM Port 12. USB PCM Audio 13. Ethernet Telnet 14. Ethernet HTTP (i.e., control hardware via a web browser!) 15. Ethernet TFTP 16. USB Host 17. Running an OS on Cortex-M3 Copyright 2011 (c), Alan Xiao 20