SlideShare a Scribd company logo
1 of 34
Download to read offline
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

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 developmentFastBit 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 1Benux 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-203Linaro
 
Developing an avr microcontroller system
Developing an avr microcontroller systemDeveloping an avr microcontroller system
Developing an avr microcontroller systemnugnugmacmac
 
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 applicationsEdgefxkits & 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 TechnologyPremier Farnell
 
3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_archchandrika
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architectureZakaria 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 setP.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: STM32F101Premier Farnell
 
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 AVRDaksh 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 ElectronicsJonathan LeBlanc
 
Programming The Arduino Due in Rust
Programming The Arduino Due in RustProgramming The Arduino Due in Rust
Programming The Arduino Due in Rustkellogh
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesLars Gregori
 
Embedded Rust on IoT devices
Embedded Rust on IoT devicesEmbedded Rust on IoT devices
Embedded Rust on IoT devicesLars Gregori
 
Stm32 f4 first touch
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touchBenux Wei
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneC4Media
 
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 environmentST_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 modulationviveksinghdew
 

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 devicenie, 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 scopeArshit Rai
 
Lcu14 101- coresight overview
Lcu14 101- coresight overviewLcu14 101- coresight overview
Lcu14 101- coresight overviewLinaro
 
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_3Raahul 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 scopeArshit Rai
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailedAnkita Tiwari
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf818Farida
 
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.pptxPratik Gohel
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduinoSantosh 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 datasheetMoises .
 
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 AnswersITExamAnswers.net
 
Cyclone II FPGA Overview
Cyclone II FPGA OverviewCyclone II FPGA Overview
Cyclone II FPGA OverviewPremier Farnell
 
NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1Andy 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

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

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