SlideShare a Scribd company logo
Let’s Play STM32 
PJayChen <n26021539@mail.ncku.edu.tw> 
Hung-Da Lin <openbox00.tw@gmail.com>
ARM Cortex-M4
ARM Processors 
•Cortex-A (Application) 
High-end embedded OS, MMU. Ex: Smart Phone 
•Cortex-R(Real-time) 
Ex: BlueRayplayers, Hard Disk Drive controllers… 
•Cortex-M(Microcontroller) 
Embedded System, replace 8051 
http://www.arm.com/index.php
ARM Cortex-M Chip
ARM Cortex-M 
•ARMv7M Architecture 
•No Cache, No MMU 
•Support DIV instruction 
•Interrupts automatically save/restore state 
•Fixed memory map 
•Thumb-2 processing core 
High code density
ARM Cortex-M
Documentation 
•The Definitive Guide To The ARM Cortex-M3 
•ARM Cortex-M3 Introduction 
•Jserv 暑期課程week3
STM32f4xx
Documentation 
•STM32F429_Datasheet 
Device features, Overview 
Device block diagram 
Memory map 
Pinoutsand pin description 
•STM32F4xx_Reference Manual 
How to use the STM32f4xx memory and peripherals 
•零死角玩轉STM32, but it’s use the Cortex-M3(STM32f10x) 
•成大資工wiki 
•STM32開機流程
Memory Mapping 
•Fixed 
•共有4G的定址範圍 
•存取特定位址則可對I/O設定 以及記憶體 
•板子預設程式起始位址為 0x8000000
STM32F4xx Standard Peripherals Library 
•透過ST提供的API來設置暫存器 
•如同初學C語言時用printf(),不用知道是如何印出字串 
•相對於直接配置暫存器的好處 
開發速度較快 
程式可讀性較佳 
•有興趣可以看Library是如何配置暫存器 
•STM32F429I-Discovery_FW_V1.0.1LibrariesSTM32F4xx_StdPeriph_Driver
CMSIS 
•CMSIS(Cortex Microcontroller Software Interface Standard) 
vendor-independent hardware abstraction layer 
便於移植程式至相同CPU(Cortex-M)的Chip
CMSIS 
•參考範例 
零死角玩轉STM32
CMSIS 
•system_stm32f4xx.c 
•系統頻率配置 可由STM32F4xx_Clock_Configuration.xls設置產生
CMSIS 
•startup_stm32f4xx.s 
•規劃stack,以及vector table位址(含Reset_Handler) 
•Reset後進入Reset_Handler 
•將data由flash搬到SRAM(Harvard architecture) 
•以及初始化bss區data成0 
•呼叫system_stm32f4xx.c的SystemInit(),進行時脈初始化 
•blmain; 跳至Entry point,如main() 
Linker scriptstartup code
Device Block Diagram 
STM32F407_datasheet
Device Block Diagram 
STM32F407_datasheet
Clock Tree 
•Clock gating 
STM32F4xx_Reference Manual
How to Use Peripherals 
GPIO Configuration 
Alternate Function Configuration 
Enable PeriphClock 
RCC_AHB1PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 
Enable Alternate function PeriphClock 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); 
Configure AF to specific GPIO 
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); 
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
GPIO 
•GPIO(General-purpose I/O) 
•可由軟體配置成不同功能 (周邊電路)的輸入或輸出 
•分成GPIOA~GPIOE組, 各組有0~15個pin角
GPIO –Input Configuration 
•配置為輸入pin 
GPIO_InitStructure.GPIO_Mode= GPIO_Mode_IN; 
•Floating, Pull-up/pull-down 
以pull-up or pull-down 電阻 
來預設空接時輸入為高電位或低電位 
GPIO_InitStructure.GPIO_PuPd= 
GPIO_PuPd_NOPULL; 
or 
GPIO_PuPd_UP; 
or 
GPIO_PuPd_DOWN;
GPIO –Output Configuration 
•配置為輸出pin 
GPIO_InitStructure.GPIO_Mode= GPIO_Mode_OUT; 
•Push-Pull 
GPIO_InitStructure.GPIO_OType= GPIO_OType_PP; 
•Open-Drain 
GPIO_InitStructure.GPIO_OType= GPIO_OType_OD;
GPIO –Analog configuration 
•配置為類比輸入/輸出pin 
GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AN; 
•由input data register讀到的值恆為0 
•用於ADC, DAC
GPIO –Alternate function configuration 
•配置為AF 
GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AF; 
•用於SPI, USART, I2C, SDIO, TIM
Exercise ! https://github.com/PJayChen/STM32f4xx_Bootloader/blob/master/src/hw_conf.c#L12
An example, How to use USART 
•Step 1, Check the AF mapping from the Datasheet 
1 
2 
3
An example, How to use USART 
•Step 2, Find the USART1 is connect to which bus
An example, How to use USART 
•Step 3, Let’s coding, Configure the system clocks 
/* USART1 clock enable */ 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); 
/* GPIOA clock enable */ 
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
An example, How to use USART 
•Step 4, Configure the GPIO 
GPIO_InitTypeDefGPIO_InitStructure; 
GPIO_InitStructure.GPIO_Pin= GPIO_Pin_9 | GPIO_Pin_10; 
GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AF; 
GPIO_InitStructure.GPIO_OType= GPIO_OType_PP; 
GPIO_InitStructure.GPIO_PuPd= GPIO_PuPd_NOPULL; 
GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz; 
GPIO_Init(GPIOA, &GPIO_InitStructure);
An example, How to use USART 
•Step 5, Connect USART with GPIO pins 
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2); //TX 
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2); //RX
An example, How to use USART 
•Step 6, Configure the USART 
//Structure With Data For USART Configuration 
USART_InitTypeDefUSART_InitStructure; 
//USART Parameters 
USART_InitStructure.USART_BaudRate= 9600; 
USART_InitStructure.USART_WordLength= USART_WordLength_8b; 
USART_InitStructure.USART_StopBits= USART_StopBits_1; 
USART_InitStructure.USART_Parity= USART_Parity_No; 
USART_InitStructure.USART_HardwareFlowControl= USART_HardwareFlowControl_None; 
USART_InitStructure.USART_Mode= USART_Mode_Rx| USART_Mode_Tx; 
//Configuring And Enabling USART1 
USART_Init(USART1, &USART_InitStructure); 
USART_Cmd(USART1, ENABLE);
An example, How to use USART 
•Step 7, Rx/Tx 
Tx 
//Wait till the flag resets 
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); 
//Send the data 
USART_SendData(USART2, data); 
Rx 
//Wait for character 
while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET) ; 
//Collect the character 
Data = USART_ReceiveData(USART2); //the data type is uint8_t
FreeRTOS
Documentation 
•成大資工分組報告 
•The Architecture of Open Source Application: FreeRTOS 
•Study of an operating system: FreeRTOS

More Related Content

What's hot

Avr introduction
Avr introductionAvr introduction
Avr introduction
Anant Shrivastava
 
Avr and arm
Avr and armAvr and arm
Avr and arm
VishwasJangra
 
Introduction to stm32-part1
Introduction to stm32-part1Introduction to stm32-part1
STM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC blockSTM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC block
FastBit Embedded Brain Academy
 
STM32 L4 presentation
STM32 L4 presentation STM32 L4 presentation
STM32 L4 presentation
Sylvie Boube-Politano
 
Part-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver developmentPart-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver development
FastBit Embedded Brain Academy
 
F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1
Benux Wei
 
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
Linaro
 
ATmega 16
ATmega 16ATmega 16
ATmega 16
Rahul Singh
 
Developing an avr microcontroller system
Developing an avr microcontroller systemDeveloping an avr microcontroller system
Developing an avr microcontroller system
nugnugmacmac
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applications
Edgefxkits & Solutions
 
8-Bit CMOS Microcontrollers with nanoWatt Technology
8-Bit CMOS Microcontrollers with nanoWatt Technology8-Bit CMOS Microcontrollers with nanoWatt Technology
8-Bit CMOS Microcontrollers with nanoWatt Technology
Premier Farnell
 
3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch
chandrika
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architecture
Zakaria Gomaa
 
AVR Microcontroller
AVR MicrocontrollerAVR Microcontroller
AVR Microcontroller
Özcan Acar
 
ARM 7 Detailed instruction set
ARM 7 Detailed instruction setARM 7 Detailed instruction set
ARM 7 Detailed instruction set
P.r. Dinesh
 
Study on 32-bit Cortex - M3 Powered MCU: STM32F101
Study on 32-bit Cortex - M3 Powered MCU: STM32F101Study on 32-bit Cortex - M3 Powered MCU: STM32F101
Study on 32-bit Cortex - M3 Powered MCU: STM32F101
Premier Farnell
 
Arm7 architecture
Arm7 architectureArm7 architecture
Arm7 architecture
Syeda Nasiha
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
Mahmoud Sadat
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVR
Daksh Raj Chopra
 

What's hot (20)

Avr introduction
Avr introductionAvr introduction
Avr introduction
 
Avr and arm
Avr and armAvr and arm
Avr and arm
 
Introduction to stm32-part1
Introduction to stm32-part1Introduction to stm32-part1
Introduction to stm32-part1
 
STM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC blockSTM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC block
 
STM32 L4 presentation
STM32 L4 presentation STM32 L4 presentation
STM32 L4 presentation
 
Part-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver developmentPart-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver development
 
F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1F9 Microkernel code reading - part 1
F9 Microkernel code reading - part 1
 
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
 
ATmega 16
ATmega 16ATmega 16
ATmega 16
 
Developing an avr microcontroller system
Developing an avr microcontroller systemDeveloping an avr microcontroller system
Developing an avr microcontroller system
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applications
 
8-Bit CMOS Microcontrollers with nanoWatt Technology
8-Bit CMOS Microcontrollers with nanoWatt Technology8-Bit CMOS Microcontrollers with nanoWatt Technology
8-Bit CMOS Microcontrollers with nanoWatt Technology
 
3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architecture
 
AVR Microcontroller
AVR MicrocontrollerAVR Microcontroller
AVR Microcontroller
 
ARM 7 Detailed instruction set
ARM 7 Detailed instruction setARM 7 Detailed instruction set
ARM 7 Detailed instruction set
 
Study on 32-bit Cortex - M3 Powered MCU: STM32F101
Study on 32-bit Cortex - M3 Powered MCU: STM32F101Study on 32-bit Cortex - M3 Powered MCU: STM32F101
Study on 32-bit Cortex - M3 Powered MCU: STM32F101
 
Arm7 architecture
Arm7 architectureArm7 architecture
Arm7 architecture
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVR
 

Viewers also liked

JavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled ElectronicsJavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled Electronics
Jonathan LeBlanc
 
Programming The Arduino Due in Rust
Programming The Arduino Due in RustProgramming The Arduino Due in Rust
Programming The Arduino Due in Rust
kellogh
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devices
Lars Gregori
 
Embedded Rust on IoT devices
Embedded Rust on IoT devicesEmbedded Rust on IoT devices
Embedded Rust on IoT devices
Lars Gregori
 
Stm32 f4 first touch
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touch
Benux Wei
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for Everyone
C4Media
 
présentation STM32
présentation STM32présentation STM32
présentation STM32
hatem ben tayeb
 
PHASE LOCK LOOPs
PHASE LOCK LOOPsPHASE LOCK LOOPs
Phase locked loop
Phase locked loopPhase locked loop
Phase locked loop
Aniruddha Chandra
 
Track 2 session 2 - st dev con 2016 - stm32 open development environment
Track 2   session 2 - st dev con 2016 - stm32 open development  environmentTrack 2   session 2 - st dev con 2016 - stm32 open development  environment
Track 2 session 2 - st dev con 2016 - stm32 open development environment
ST_World
 
Speed control of dc motor using pulse width modulation
Speed control of dc motor using pulse width modulationSpeed control of dc motor using pulse width modulation
Speed control of dc motor using pulse width modulation
viveksinghdew
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 

Viewers also liked (12)

JavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled ElectronicsJavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled Electronics
 
Programming The Arduino Due in Rust
Programming The Arduino Due in RustProgramming The Arduino Due in Rust
Programming The Arduino Due in Rust
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devices
 
Embedded Rust on IoT devices
Embedded Rust on IoT devicesEmbedded Rust on IoT devices
Embedded Rust on IoT devices
 
Stm32 f4 first touch
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touch
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for Everyone
 
présentation STM32
présentation STM32présentation STM32
présentation STM32
 
PHASE LOCK LOOPs
PHASE LOCK LOOPsPHASE LOCK LOOPs
PHASE LOCK LOOPs
 
Phase locked loop
Phase locked loopPhase locked loop
Phase locked loop
 
Track 2 session 2 - st dev con 2016 - stm32 open development environment
Track 2   session 2 - st dev con 2016 - stm32 open development  environmentTrack 2   session 2 - st dev con 2016 - stm32 open development  environment
Track 2 session 2 - st dev con 2016 - stm32 open development environment
 
Speed control of dc motor using pulse width modulation
Speed control of dc motor using pulse width modulationSpeed control of dc motor using pulse width modulation
Speed control of dc motor using pulse width modulation
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
 

Similar to Let's Play STM32

SoM with Zynq UltraScale device
SoM with Zynq UltraScale deviceSoM with Zynq UltraScale device
SoM with Zynq UltraScale device
nie, jack
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
Arshit Rai
 
Lcu14 101- coresight overview
Lcu14 101- coresight overviewLcu14 101- coresight overview
Lcu14 101- coresight overview
Linaro
 
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
Raahul Raghavan
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
Arshit Rai
 
Phytium 64 core cpu preview
Phytium 64 core cpu previewPhytium 64 core cpu preview
Phytium 64 core cpu preview
inside-BigData.com
 
Pic16 c7x
Pic16 c7xPic16 c7x
Pic16 c7x
sharmeejeyam
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
Ankita Tiwari
 
Pic16f84
Pic16f84Pic16f84
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
818Farida
 
Track 5 session 3 - st dev con 2016 - mechanisms for trusted code execution...
Track 5   session 3 - st dev con 2016 - mechanisms for trusted code execution...Track 5   session 3 - st dev con 2016 - mechanisms for trusted code execution...
Track 5 session 3 - st dev con 2016 - mechanisms for trusted code execution...
ST_World
 
Introduction to embedded System.pptx
Introduction to embedded System.pptxIntroduction to embedded System.pptx
Introduction to embedded System.pptx
Pratik Gohel
 
Ii avr-basics(1)
Ii avr-basics(1)Ii avr-basics(1)
Ii avr-basics(1)
Thakur Satyajeetsinh Dodiya
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
Santosh Verma
 
Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...
Alexander Bolshev
 
Esp32 datasheet
Esp32 datasheetEsp32 datasheet
Esp32 datasheet
Moises .
 
IT Essentials (Version 7.0) - ITE Chapter 1 Exam Answers
IT Essentials (Version 7.0) - ITE Chapter 1 Exam AnswersIT Essentials (Version 7.0) - ITE Chapter 1 Exam Answers
IT Essentials (Version 7.0) - ITE Chapter 1 Exam Answers
ITExamAnswers.net
 
Processors selection
Processors selectionProcessors selection
Processors selection
Pradeep Shankhwar
 
Cyclone II FPGA Overview
Cyclone II FPGA OverviewCyclone II FPGA Overview
Cyclone II FPGA Overview
Premier Farnell
 
NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1
Andy Gelme
 

Similar to Let's Play STM32 (20)

SoM with Zynq UltraScale device
SoM with Zynq UltraScale deviceSoM with Zynq UltraScale device
SoM with Zynq UltraScale device
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
Lcu14 101- coresight overview
Lcu14 101- coresight overviewLcu14 101- coresight overview
Lcu14 101- coresight overview
 
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
Phytium 64 core cpu preview
Phytium 64 core cpu previewPhytium 64 core cpu preview
Phytium 64 core cpu preview
 
Pic16 c7x
Pic16 c7xPic16 c7x
Pic16 c7x
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
Pic16f84
Pic16f84Pic16f84
Pic16f84
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
 
Track 5 session 3 - st dev con 2016 - mechanisms for trusted code execution...
Track 5   session 3 - st dev con 2016 - mechanisms for trusted code execution...Track 5   session 3 - st dev con 2016 - mechanisms for trusted code execution...
Track 5 session 3 - st dev con 2016 - mechanisms for trusted code execution...
 
Introduction to embedded System.pptx
Introduction to embedded System.pptxIntroduction to embedded System.pptx
Introduction to embedded System.pptx
 
Ii avr-basics(1)
Ii avr-basics(1)Ii avr-basics(1)
Ii avr-basics(1)
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...
 
Esp32 datasheet
Esp32 datasheetEsp32 datasheet
Esp32 datasheet
 
IT Essentials (Version 7.0) - ITE Chapter 1 Exam Answers
IT Essentials (Version 7.0) - ITE Chapter 1 Exam AnswersIT Essentials (Version 7.0) - ITE Chapter 1 Exam Answers
IT Essentials (Version 7.0) - ITE Chapter 1 Exam Answers
 
Processors selection
Processors selectionProcessors selection
Processors selection
 
Cyclone II FPGA Overview
Cyclone II FPGA OverviewCyclone II FPGA Overview
Cyclone II FPGA Overview
 
NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1
 

Recently uploaded

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
Edge AI and Vision Alliance
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 

Recently uploaded (20)

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 

Let's Play STM32

  • 1. Let’s Play STM32 PJayChen <n26021539@mail.ncku.edu.tw> Hung-Da Lin <openbox00.tw@gmail.com>
  • 3. ARM Processors •Cortex-A (Application) High-end embedded OS, MMU. Ex: Smart Phone •Cortex-R(Real-time) Ex: BlueRayplayers, Hard Disk Drive controllers… •Cortex-M(Microcontroller) Embedded System, replace 8051 http://www.arm.com/index.php
  • 5. ARM Cortex-M •ARMv7M Architecture •No Cache, No MMU •Support DIV instruction •Interrupts automatically save/restore state •Fixed memory map •Thumb-2 processing core High code density
  • 7. Documentation •The Definitive Guide To The ARM Cortex-M3 •ARM Cortex-M3 Introduction •Jserv 暑期課程week3
  • 9. Documentation •STM32F429_Datasheet Device features, Overview Device block diagram Memory map Pinoutsand pin description •STM32F4xx_Reference Manual How to use the STM32f4xx memory and peripherals •零死角玩轉STM32, but it’s use the Cortex-M3(STM32f10x) •成大資工wiki •STM32開機流程
  • 10. Memory Mapping •Fixed •共有4G的定址範圍 •存取特定位址則可對I/O設定 以及記憶體 •板子預設程式起始位址為 0x8000000
  • 11. STM32F4xx Standard Peripherals Library •透過ST提供的API來設置暫存器 •如同初學C語言時用printf(),不用知道是如何印出字串 •相對於直接配置暫存器的好處 開發速度較快 程式可讀性較佳 •有興趣可以看Library是如何配置暫存器 •STM32F429I-Discovery_FW_V1.0.1LibrariesSTM32F4xx_StdPeriph_Driver
  • 12. CMSIS •CMSIS(Cortex Microcontroller Software Interface Standard) vendor-independent hardware abstraction layer 便於移植程式至相同CPU(Cortex-M)的Chip
  • 14. CMSIS •system_stm32f4xx.c •系統頻率配置 可由STM32F4xx_Clock_Configuration.xls設置產生
  • 15. CMSIS •startup_stm32f4xx.s •規劃stack,以及vector table位址(含Reset_Handler) •Reset後進入Reset_Handler •將data由flash搬到SRAM(Harvard architecture) •以及初始化bss區data成0 •呼叫system_stm32f4xx.c的SystemInit(),進行時脈初始化 •blmain; 跳至Entry point,如main() Linker scriptstartup code
  • 16. Device Block Diagram STM32F407_datasheet
  • 17. Device Block Diagram STM32F407_datasheet
  • 18. Clock Tree •Clock gating STM32F4xx_Reference Manual
  • 19. How to Use Peripherals GPIO Configuration Alternate Function Configuration Enable PeriphClock RCC_AHB1PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); Enable Alternate function PeriphClock RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); Configure AF to specific GPIO GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
  • 20. GPIO •GPIO(General-purpose I/O) •可由軟體配置成不同功能 (周邊電路)的輸入或輸出 •分成GPIOA~GPIOE組, 各組有0~15個pin角
  • 21. GPIO –Input Configuration •配置為輸入pin GPIO_InitStructure.GPIO_Mode= GPIO_Mode_IN; •Floating, Pull-up/pull-down 以pull-up or pull-down 電阻 來預設空接時輸入為高電位或低電位 GPIO_InitStructure.GPIO_PuPd= GPIO_PuPd_NOPULL; or GPIO_PuPd_UP; or GPIO_PuPd_DOWN;
  • 22. GPIO –Output Configuration •配置為輸出pin GPIO_InitStructure.GPIO_Mode= GPIO_Mode_OUT; •Push-Pull GPIO_InitStructure.GPIO_OType= GPIO_OType_PP; •Open-Drain GPIO_InitStructure.GPIO_OType= GPIO_OType_OD;
  • 23. GPIO –Analog configuration •配置為類比輸入/輸出pin GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AN; •由input data register讀到的值恆為0 •用於ADC, DAC
  • 24. GPIO –Alternate function configuration •配置為AF GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AF; •用於SPI, USART, I2C, SDIO, TIM
  • 26. An example, How to use USART •Step 1, Check the AF mapping from the Datasheet 1 2 3
  • 27. An example, How to use USART •Step 2, Find the USART1 is connect to which bus
  • 28. An example, How to use USART •Step 3, Let’s coding, Configure the system clocks /* USART1 clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); /* GPIOA clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  • 29. An example, How to use USART •Step 4, Configure the GPIO GPIO_InitTypeDefGPIO_InitStructure; GPIO_InitStructure.GPIO_Pin= GPIO_Pin_9 | GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType= GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd= GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure);
  • 30. An example, How to use USART •Step 5, Connect USART with GPIO pins GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2); //TX GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2); //RX
  • 31. An example, How to use USART •Step 6, Configure the USART //Structure With Data For USART Configuration USART_InitTypeDefUSART_InitStructure; //USART Parameters USART_InitStructure.USART_BaudRate= 9600; USART_InitStructure.USART_WordLength= USART_WordLength_8b; USART_InitStructure.USART_StopBits= USART_StopBits_1; USART_InitStructure.USART_Parity= USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl= USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode= USART_Mode_Rx| USART_Mode_Tx; //Configuring And Enabling USART1 USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE);
  • 32. An example, How to use USART •Step 7, Rx/Tx Tx //Wait till the flag resets while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); //Send the data USART_SendData(USART2, data); Rx //Wait for character while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET) ; //Collect the character Data = USART_ReceiveData(USART2); //the data type is uint8_t
  • 34. Documentation •成大資工分組報告 •The Architecture of Open Source Application: FreeRTOS •Study of an operating system: FreeRTOS