STM32F4使用手册

合集下载

STM32F40x 41x微控制器时钟配置工具说明书

STM32F40x 41x微控制器时钟配置工具说明书

2011 年 10 月文档 ID 022298 第 1 版1/21AN3988应用笔记适用于 STM32F40x/41x 微控制器的时钟配置工具简介本应用笔记介绍了适用于 STM32F4xx 微控制器系列的时钟系统配置工具。

此工具的目的是帮助用户配置微控制器时钟,并将电源和 Flash 访问模式等参数考虑在内。

此配置工具在“STM32F4xx_Clock_Configuration_VX.Y .Z.xls ”文件中实现,该文件随 STM32F4xx 标准外设库提供,并可以从 下载。

此工具支持 STM32F4xx 的下列功能:●配置系统时钟、HCLK 源和输出频率。

●配置 Flash 延迟(等待周期数取决于 HCLK 频率)。

●设置 PCLK1、PCLK2、TIMCLK (定时器时钟)、USBCLK 和 I2SCLK 频率。

●生成含有上述全部设置的可直接使用的 system_stm32f4xx.c 文件(STM32F4xx CMSIS Cortex-M4 器件外设访问层系统源文件)。

在本文档中,STM32F4xx_Clock_Configuration_VX.Y .Z.xls 称为“时钟工具”。

在使用时钟工具之前,必须阅读 STM32F4xx 微控制器参考手册 (RM0090)。

本应用笔记不是参考手册的替代。

此工具仅支持 A 版 STM32F4xx 。

注:对于 VX.Y .Z ,请参见工具版本,例如 V1.0.0目录AN3988目录1词汇表 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52使用入门 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.1软件要求 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2硬件要求 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.1简介 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.2STM32F4xx 微控制器的时钟方案 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.3I2S 时钟发生器 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93教程 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1向导模式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.1分步过程 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2专家模式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4已知限制 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5结论 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6版本历史 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202/21文档 ID 022298 第 1 版AN3988表格索引表格索引表 1.术语定义. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5表 2.等待周期数与 CPU 时钟 (HCLK) 频率对应关系 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9表 3.文档版本历史 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20文档 ID 022298 第 1 版3/21图片索引AN3988图片索引图 1.时钟方案. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8图 2.I2S 时钟发生器架构 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9图 3.向导模式用户界面. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11图 4.HSE 值超出范围. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12图 5.VDD 超出范围. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12图 6.HCLK 错误消息. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13图 7.选择时钟源 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13图 8.无可用配置错误. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14图 9.文件生成错误 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14图 10.专家模式用户界面. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15图 11.超出系统时钟频率. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16图 12.超出 PLL 输入频率 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16图 13.I2S 频率超出范围 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4/21文档 ID 022298 第 1 版AN3988词汇表1 词汇表表 1.术语定义术语说明HCLK AHB 时钟PCLK1APB1 时钟PCLK2APB2 时钟TIMCLK定时器时钟USB OTG FS USB 全速 OTGF CPU Cortex-M4 时钟Ext.Clock外部时钟V DD电源HSI高速内部时钟HSE高速外部时钟MCLK主时钟I2S内部集成音频Fs采样频率I2SCLK I2S 时钟RNG随机数发生器SDIO安全数字输入/输出接口文档 ID 022298 第 1 版5/21使用入门AN3988 2 使用入门本节介绍开始使用时钟工具所需的系统要求和步骤。

STM32F4Discovery 扩展板用户手册

STM32F4Discovery 扩展板用户手册

STM32F407 Discovery ExtBoard用户手册版本 2011-05-01(本手册不断更新,建议您在官方网站下载最新版本)版权声明本手册版权归属天津淘淘科技电子有限公司(以下简称“淘淘科技”)所有, 并保留一切权力。

非经淘淘科技同意(书面形式),任何单位及个人不得擅自摘录本手册部分或全部,违者我们将追究其法律责任。

敬告:在售开发板的手册会经常更新,请在 网站查看最近更新,并下载最新手册,恕不再另行通知。

更新说明日期说明2012-05-01 本手册第一次发布目录1.1 STM32F407 Discovery ExtBoard开发板简介STM32F407 Discovery ExtBoard(下简称“本开发板”)是一款十分精致的低价高品质一体化STM32F407 Discovery CortexM4扩展开发板,由天津淘淘科技设计、生产和发行销售。

它采用STM32F407 Discovery作为核心板(下简称“核心板”),在设计上最大限度的贴近STM公司的开发板“精细”的风格,而且布局更加合理,接口更加丰富,十分适用于开发 MID、汽车电子、工业控制、导航系统、媒体播放等终端设备;也可适用于高校教学、嵌入式培训、个人研究学习和DIY 等。

具体而言,本开发板除了保留原有核心板的重力感应、三轴加速度传感器、miniUSB(A-B两种接口)、3.5mm 音频输出口、100PIN GPIO、LED、用户按键以外,本开发板还扩展了 LCD、4 线电阻触摸屏接口、100M 标准网络接口、DB9 串口、CAN总线接口、SD 卡接口、数字Camera接口,并为用户提供了AD 可调电阻等。

所有这些,都极大地方便了开发者的评估和使用,再加上我们按照本开发板尺寸专门定制的 LCD 模块,真正做到充分发挥STM官方原装开发板的强大功能。

我们还充分地发挥了原装开发板在线调试的ST-Link/v2,您不必再额外购买JTAG仿真器等调试设备,仅需要一根usb线就可以在尽情发挥CortexM4的特性。

STM32F4xxx 参考手册学习摘录

STM32F4xxx 参考手册学习摘录

2存储器和总线架构64 KB CCM(内核耦合存储器)数据RAM 不属于总线矩阵,只能通过CPU 对其进行访问。

对APB 寄存器执行16 位或8 位访问时,该访问将转换为32 位访问:总线桥将16 位或8 位数据复制后提供给32 位向量。

存储器组织结构程序存储器、数据存储器、寄存器和I/O 端口排列在同一个顺序的 4 GB 地址空间内。

各字节按小端格式在存储器中编码。

字中编号最低的字节被视为该字的最低有效字节,而编号最高的字节被视为最高有效字节。

嵌入式SRAMSTM32F405xx/07xx 和STM32F415xx/17xx 带有4 KB 备份SRAM(请参见第5.1.2 节:电池备份域)和192 KB 系统SRAM系统SRAM 分为三个块:●映射在地址0x2000 0000 的112 KB 和16 KB 块●映射在地址0x2002 0000 的64 KB 块,(适用于STM32F42xxx 和STM32F43xxx)。

AHB 主总线支持并发SRAM 访问(通过以太网或USB OTG HS):例如,当CPU 对112 KB 或64 KB SRAM 进行读/写操作时,以太网MAC 可以同时对16 KB SRAM 进行读/写操作。

●在地址0x1000 0000 映射的64 KB 块,只能供CPU 通过数据总线访问。

位段Cortex™-M4F 存储器映射包括两个位段区域。

这些区域将存储器别名区域中的每个字映射到存储器位段区域中的相应位。

在别名区域写入字时,相当于对位段区域的目标位执行读-修改-写操作。

bit_word_addr = bit_band_base + (byte_offset x 32) + (bit_number × 4)BOOT0 为专用引脚,而BOOT1 则与GPIO 引脚共用。

一旦完成对BOOT1 的采样,相应GPIO 引脚即进入空闲状态,可用于其它用途。

器件退出待机模式时,还会对BOOT 引脚重新采样。

stm32f4 flash读写例程

stm32f4 flash读写例程

一、概述STM32F4是ST公司推出的一款高性能的32位微控制器,它具有强大的性能和丰富的外设资源,广泛应用于工业控制、消费电子、通信设备等领域。

其中,STM32F4的Flash存储器模块具有较大的存储容量和快速的读写速度,非常适合用来存储程序代码和数据。

本文将介绍如何使用STM32F4的Flash存储器模块进行读写操作的例程。

二、开发环境准备1. 基本硬件准备:准备一块STM32F4开发板,如STM32F407ZGT6开发板。

一台电脑,安装了Keil或者其他的开发环境。

2. 软件准备:在电脑上安装好STM32CubeMX和Keil或者其他的开发环境。

三、创建工程1. 打开STM32CubeMX,新建一个工程,选择对应的芯片型号,例如选择STM32F407ZGT6。

2. 配置时钟树,使得系统时钟为想要的频率,一般选择高频率以获得更快的Flash读写速度。

3. 配置Flash存储器,选择合适的扇区大小和擦写次数。

4. 生成代码,导出工程。

四、编写代码1. 在Keil或者其他的开发环境中打开刚刚生成的工程。

2. 找到Flash读写相关的API,一般在芯片提供的库函数中可以找到。

3. 根据需要编写Flash读写的代码,例如可以编写一个函数来实现向Flash写入数据的功能。

五、编译下载1. 编译代码,生成bin文件。

2. 将bin文件下载到STM32F4开发板中,可以使用ST-Link或者其他下载工具来完成。

六、调试运行1. 确保下载成功,重启开发板。

2. 进行调试,观察Flash读写是否正常。

七、注意事项1. 在进行Flash写入操作时,一定要小心谨慎,避免对程序的正常运行造成影响。

2. 在进行Flash擦除操作时,务必注意擦除的范围,避免擦除了不该擦除的数据。

3. 在进行Flash读写操作时,需要留意Flash的特性和限制,以免造成不必要的麻烦。

八、总结本文介绍了如何在STM32F4开发板上使用Flash存储器进行读写操作的例程,从开发环境准备到代码编写再到调试运行都有详细的步骤说明,并给出了注意事项和总结。

STM32CubeF4例程使用说明

STM32CubeF4例程使用说明

February 2014DocID025922 Rev 11/22UM1730User manualGetting started with STM32CubeF4 firmware packagefor STM32F4xx seriesIntroductionThe STM32Cube ™ initiative was originated by STMicroelectronics to ease developers life by reducing development efforts, time and cost. STM32Cube ™ covers the STM32 portfolio.STM32Cube Version 1.x includes:•The STM32CubeMX, a graphical software configuration tool that allows to generate C initialization code using graphical wizards • A comprehensive embedded software platform, delivered per series (such as STM32CubeF4 for STM32F4 series)–The STM32Cube HAL, an STM32 abstraction layer embedded software, ensuring maximized portability across the STM32 portfolio –A consistent set of middleware components such as RTOS, USB, TCP/IP and graphics –All embedded software utilities coming with a full set of examples.This user manual describes how to get started with the STM32CubeF4 firmware package. Section 1 describes the main features of STM32CubeF4 firmware, part of theSTM32Cube ™ initiative.Section 2 and Section 3 provide an overview of the STM32CubeF4 architecture andfirmware package structure.Contents UM1730Contents1STM32CubeF4 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2STM32CubeF4 architecture overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 63STM32CubeF4 firmware package overview . . . . . . . . . . . . . . . . . . . . . . 93.1Supported STM32F4 devices and hardware . . . . . . . . . . . . . . . . . . . . . . . 93.2Firmware package overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.1How to run your first example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2How to develop your own application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.3Using STM32CubeMX for generating the initialization C code . . . . . . . . 174.4How to get STM32CubeF4 release updates . . . . . . . . . . . . . . . . . . . . . . 184.4.1How to install and run the STM32CubeUpdater program . . . . . . . . . . . 18 5FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212/22DocID025922 Rev 1UM1730List of tables List of tablesTable 1.Macros for STM32F4 series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Table 2.Evaluation and Discovery boards for STM32F4 series. . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Table 3.Number of examples available for each board. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Table 4.Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21DocID025922 Rev 13/22List of figures UM1730 List of figuresFigure 1.STM32CubeF4 firmware components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 2.STM32CubeF4 firmware architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 3.STM32CubeF4 firmware package structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 4.STM32CubeF4 examples overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4/22DocID025922 Rev 1DocID025922 Rev 15/22UM1730STM32CubeF4 main features 1 STM32CubeF4 main featuresSTM32CubeF4 gathers together, in a single package, all the generic embedded softwarecomponents required to develop an application on STM32F4 microcontrollers. In line withthe STM32Cube initiative, this set of components is highly portable, not only within theSTM32F4 series but also to other STM32 series.STM32CubeF4 is fully compatible with STM32CubeMX code generator that allows the userto generate initialization code. The package includes a low level hardware abstraction layer(HAL) that covers the microcontroller hardware, together with an extensive set of examplesrunning on STMicroelectronics boards. The HAL is available in an open-source BSD licensefor user convenience.STM32CubeF4 package also contains a set of middleware components with thecorresponding examples. They come with very permissive license terms:•Full USB Host and Device stack supporting many classes.–Host Classes: HID, MSC, CDC, Audio, MTP –Device Classes: HID, MSC, CDC, Audio, DFU •STemWin, a professional graphical stack solution available in binary format and based on the emWin solution from ST's partner Segger •CMSIS-RTOS implementation with FreeRTOS open source solution •FAT File system based on open source FatFS solution •TCP/IP stack based on open source LwIP solution •SSL/TLS secure layer based on open source PolarSSLA demonstration implementing all these middleware components is also provided in theSTM32CubeF4 package.2 STM32CubeF4 architecture overviewThe STM32CubeF4 firmware solution is built around three independent levels that caneasily interact with each other as described in the Figure 1 below:Level 0: This level is divided into three sub-layers:•Board Support Package (BSP): this layer offers a set of APIs related to the hardware components on the hardware boards (Audio codec, I/O expander, Touchscreen, SRAMdriver, LCD drivers. etc…) and composed of two parts:–Component: is the driver related to the external device on the board and notrelated to the STM32, the component driver provides specific APIs to the BSPdriver’s external components and can be ported to any board.–BSP driver: it enables the component driver to be linked to a specific board and provides a set of user-friendly APIs. The API naming rule isBSP_FUNCT_Action(): ex. BSP_LED_Init(),BSP_LED_On()It's based on a modular architecture that allows it to be ported easily to any hardwareby just implementing the low level routines.•Hardware Abstraction Layer (HAL): this layer provides the low level drivers and theand stacks). It provides generic, multi instance and function-oriented APIs which allowto offload the user application implementation by providing ready-to-use processes. Forexample, for the communication peripherals (I2S, UART…) it provides APIs allowing to6/22DocID025922 Rev 1initialize and configure the peripheral, manage data transfer based on polling, interrupt or DMA process, and manage communication errors that may raise duringcommunication. The HAL Drivers APIs are split in two categories, generic APIs which provides common and generic functions to all the STM32 series and extension APIs which provides specific and customized functions for a specific family or a specific part number.•Basic peripheral usage examples: this layer contains examples of basic operation of the STM32F4 peripherals using only the HAL and BSP resources.Level 1: This level is divided into two sub-layers:•Middleware components: a set of Libraries covering USB Host and Device Libraries, STemWin, FreeRTOS, FatFS, LwIP, and PolarSSL. Horizontal interactions between the components of this layer are done directly by calling the feature APIs while the vertical interaction with the low level drivers is done through specific callbacks and staticmacros implemented in the library system call interface. For example, the FatFsimplements the disk I/O driver to access microSD drive or the USB Mass StorageClass.The main features of each Middleware component are as follows:USB Host and Device Libraries–Several USB classes supported (Mass-Storage, HID, CDC, DFU, AUDIO, MTP)–Supports multi packet transfer features: allows sending big amounts of data without splitting them into max packet size transfers.–Uses configuration files to change the core and the library configuration without changing the library code (Read Only).–Includes 32-bit aligned data structures to handle DMA-based transfer in High-speed modes.–Supports multi USB OTG core instances from user level through configuration file (allows operation with more than one USB host/device peripheral).–RTOS and Standalone operation–The link with low-level driver is done through an abstraction layer using the configuration file to avoid any dependency between the Library and the low-levelsolution–Optimized display drivers–Software tools for code generation and bitmap editing (STemWin Builder…)FreeRTOS–Open source standard–CMSIS compatibility layer–Tickless operation during low-power mode–Integration with all STM32Cube Middleware modulesDocID025922 Rev 17/22FAT File system–FATFS FAT open source library–Long file name support–Dynamic multi-drive support–RTOS and standalone operation–Examples with microSD and USB host Mass-storage classLwIP TCP/IP stack–Open source standard–RTOS and standalone operation•Examples based on the Middleware components: each Middleware component comes with one or more examples (called also Applications) showing how to use it.Integration examples that use several Middleware components are provided as well.Level 2: This level is composed of a single layer which is a global real-time and graphicaldemonstration based on the Middleware service layer, the low level abstraction layer andthe applications that make basic use of the peripherals for board-based functions.8/22DocID025922 Rev 1DocID025922 Rev 19/223STM32CubeF4 firmware package overview 3.1 Supported STM32F4 devices and hardwareSTM32Cube offers a highly portable Hardware Abstraction Layer (HAL) built around ageneric and modular architecture allowing the upper layers, Middleware and Application, toimplement its functions without in-depth knowledge of the MCU being used. This improvesthe library code re-usability and guarantees an easy portability from one device to another.The STM32CubeF4 offers full support for all STM32F4 Series devices. You only have todefine the right macro in stm32f4xx.h.Table 1 below lists which macro to define depending on the STM32F4 device you are using(this macro can also be defined in the compiler preprocessor).STM32CubeF4 features a rich set of examples and demonstrations at all levels making iteasy to understand and use any HAL driver and/or Middleware components. These Table 1. Macros for STM32F4 seriesMacro defined instm32f4xx.h STM32F4 devicesSTM32F405xx STM32F405RG, STM32F405VG and STM32F405ZGSTM32F415xx STM32F415RG, STM32F415VG and STM32F415ZGSTM32F407xx STM32F407VG, STM32F407VE, STM32F407ZG, STM32F407ZE,STM32F407IG and STM32F407IESTM32F417xx STM32F417VG, STM32F417VE, STM32F417ZG, STM32F417ZE,STM32F417IG and STM32F417IESTM32F427xx STM32F427VG, STM32F427VI, STM32F427ZG, STM32F427ZI,STM32F427IG and STM32F427IISTM32F437xx STM32F437VG, STM32F437VI, STM32F437ZG, STM32F437ZI,STM32F437IG and STM32F437IISTM32F429xx STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI,STM32F429BG, STM32F429BI, STM32F429NG, STM32F439NI,STM32F429IG and STM32F429IISTM32F439xx STM32F439VG, STM32F439VI, STM32F439ZG, STM32F439ZI,STM32F439BG, STM32F439BI, STM32F439NG, STM32F439NI,STM32F439IG and STM32F439IISTM32F401xC STM32F401CB, STM32F401CC, STM32F401RB, STM32F401RC,STM32F401VB and STM32F401VCSTM32F401xESTM32F401CD, STM32F401RD, STM32F401VD, STM32F401CE,STM32F401RE, STM32F401VEexamples can be run on any of the STMicroelectronics boards as listed in Table 2 below:Table 2. Evaluation and Discovery boards for STM32F4 seriesThe STM32CubeF4 firmware is able to run on any compatible hardware. This means youcan simply update the BSP drivers to port the provided examples to your own board, if it hasthe same hardware functions (LED, LCD display, pushbuttons...etc.).overview3.2 FirmwarepackageThe STM32CubeF4 firmware solution is provided in a single zip package with the structureshown in Figure 3 below.10/22DocID025922 Rev 1For each board, a set of examples are provided with preconfigured projects for EWARM, MDK-ARM and TrueSTUDIO toolchains.Figure 4 shows the project structure for the STM324xG-EVAL board. The structure is identical for other boards.The examples are classified depending on the STM32Cube level they apply to, and are named as follows:•Examples in level 0 are called Examples, that use HAL drivers without any Middleware component•Examples in level 1 are called Applications, that provide typical use cases of each Middleware component•Examples in level 2 are called Demonstration, that implement all the HAL, BSP and Middleware componentsA Template project is provided to allow you to quickly build any firmware application on agiven board.DocID025922 Rev 111/22All examples have the same structure,•\Inc folder that contains all header files•\Src folder for the sources code•\EWARM, \MDK-ARM and \TrueSTUDIO folders contain the preconfigured project for each toolchain.•readme.txt describing the example behavior and the environment required to make it work12/22DocID025922 Rev 1Figure 4. STM32CubeF4 examples overviewDocID025922 Rev 113/22Table 3 provides the number of examples, applications and demonstrations available foreach board.Table 3. Number of examples available for each boardBoard Examples Applications Demonstration STM324x9I_EVAL83561STM324xG_EVAL68521STM32F4-Discovery2241STM32F401-Discovery2041STM32F429I-Discovery2681STM32F4xx-Nucleo3NA NA14/22DocID025922 Rev 1UM1730Getting startedstarted4 Getting4.1 How to run your first exampleThis section explains how simple it is to run a first example with STM32CubeF4. As anillustration let's consider to run a simple LED toggling example running on the STM32F4-Discovery board:1.After downloading the STM32CubeF4 firmware package, unzip it into a directory ofyour choice, you just need to ensure that the package structure is not modified (asshown in Figure 3 above).2. Browse to \Projects\STM32F4-Discovery\Examples.3. Open \GPIO, then the \GPIO_EXTI folder.4. Open the project with your preferred toolchain.5. Rebuild all files and load your image into target memory.6. Run the example: each time you press User button 4, the LEDs will toggle (for moredetails, refer to the example readme file).You will get a quick overview of how to open, build and run an example with thesupported toolchains.•EWARM–Under the example folder, open the \EWARM subfolder–Open the Project.eww workspace(a)–Rebuild all files: Project->Rebuild all–Load project image: Project->Debug–Run program: Debug->Go(F5)•MDK-ARM–Under the example folder, open the \MDK-ARM subfolder–Open the Project.uvproj workspace(a)–Rebuild all files: Project->Rebuild all target files–Load project image: Debug->Start/Stop Debug Session–Run program: Debug->Run (F5)•TrueSTUDIO–Open the TrueSTUDIO toolchain–Click on File->Switch Workspace->Other and browse to the TrueSTUDIOworkspace directory–Click on File->Import, select General->'Existing Projects into Workspace' and then click “Next”.–Browse to the TrueSTUDIO workspace directory, select the project–Rebuild all project files: Select the project in the “Project explorer” window then click on Project->build project menu.–Run program: Run->Debug (F11)a.The workspace name may change from one example to anotherDocID025922 Rev 115/22Getting started UM17304.2 How to develop your own applicationThis section describes the required steps needed to create your own application usingSTM32CubeF4.1.Create your project: to create a new project you can either start from the Templateproject provided for each board under \Projects\<STM32xx_xxx>\Templates or fromany available project under \Projects\<STM32xx_xxx>\Examples or\Projects\<STM32xx_xxx>\Applications (<STM32xx_xxx> refers to the board name, ex.STM32F4-Discovery).The Template project provides an empty main loop function, this is a good starting pointto allow you to get familiar with the project settings for STM32CubeF4. It has thefollowing characteristics:a) It contains sources of the HAL, CMSIS and BSP drivers which are the minimumrequired components to develop code for a given boardb) It contains the include paths for all the firmware componentsc) It defines the STM32F4 device supported, allowing to have the right configurationfor the CMSIS and HAL driversd) It provides ready-to-use user files preconfigured as follows:- HAL is initialized- SysTick ISR implemented for HAL_Delay() purpose- System clock is configured with the maximum frequency of the deviceNote:If you copy an existing project to another location, then you need to update the include paths.2. Add the necessary Middleware to your project (optional): available Middlewarestacks are: USB Host and Device Libraries, STemWin, FreeRTOS, FatFS, LwIP, andPolarSSL. To find out which source files you need to add to the project files list, refer tothe documentation provided for each Middleware, you can also have a look at theapplications available under \Projects\STM32xx_xxx\Applications\<MW_Stack>(<MW_Stack> refers to the Middleware stack, for example USB_Device) to get a betteridea of the source files to be added and the include paths.3. Configure the firmware components: the HAL and Middleware components offer aset of build time configuration options using macros declared with “#define” in a headerfile. A template configuration file is provided within each component, which you have tocopy to the project folder (usually the configuration file is named xxx_conf_template.h.The word “_template” needs to be removed when copying it to the project folder). Theconfiguration file provides enough information to know the effect of each configurationoption. More detailed information is available in the documentation provided for eachcomponent.4. Start the HAL Library: after jumping to the main program, the application code needsUM1730Getting started5. Configure the system clock: the system clock configuration is done by calling thesetwo APIsa) HAL_RCC_OscConfig(): configures the internal and/or external oscillators, PLLsource and factors. You can choose to configure one oscillator or all oscillators.You can also skip the PLL configuration if there is no need to run the system athigh frequencyb) HAL_RCC_ClockConfig(): configures the system clock source, Flash latency andAHB and APB prescalers6. Develop your application process: at this stage, your system is ready and you canstart developing your application code.a) The HAL provides intuitive and ready-to-use APIs for configuring the peripheral,and supports polling, interrupt and DMA programming models, to accommodateany application requirements. For more details on how to use each peripheral,refer to the rich examples set provided.b) If your application has some real-time constraints, you can find a large set ofexamples showing how to use FreeRTOS and integrate it with all Middlewarestacks provided in STM32CubeF4, it can be a good starting point for yourdevelopment.c) IMPORTANT NOTE: care must be taken when using HAL_Delay(). This functionprovides an accurate delay (in milliseconds) based on a variable incremented inSysTick ISR. This implies that if HAL_Dely() is called from a peripheral ISRprocess, then the SysTick interrupt must have the highest priority (numericallylower) than the peripheral interrupt. Otherwise the caller ISR process will beblocked. To change the SysTick interrupt priority, you have to use theHAL_NVIC_SetPriority() function.4.3 Using STM32CubeMX for generating the initialization C codeAnother alternative to Steps 1 to 5 described in Section 4.2 consists in using theSTM32CubeMX tool to easily generate code for the initialization of the system, theperipherals and middleware (Steps 1 to 5 above) through a step-by-step process:•Selection of the STMicroelectronics STM32 microcontroller that matches the required set of peripherals.•Configuration of each required embedded software thanks to a pinout-conflict solver, a clock-tree setting helper, a power consumption calculator, and an utility performingMCU peripheral configuration (GPIO, USART...) and middleware stacks (USB,TCP/IP...).•Generation of the initialization C code based on the configuration selected. This code is ready to be used within several development environments. The user code is kept atthe next code generation.For more information, please refer to UM1718.DocID025922 Rev 117/22Getting started UM173018/22DocID025922 Rev 14.4 How to get STM32CubeF4 release updatesThe STM32CubeF4 firmware package comes with an updater utility: STM32CubeUpdater,also available as a menu within STM32CubeMX code generation tool.The updater solution detects new firmware releases and patches available from andproposes to download them to the user’s computer.4.4.1 How to install and run the STM32CubeUpdater program•Double-click SetupSTM32CubeUpdater.exe file to launch the installation.•Accept the license terms and follow the different installation steps.Upon successful installation, STM32CubeUpdater becomes available as an STMicroelectronics program under Program Files and is automatically launched.The STM32CubeUpdater icon appears in the system tray:•Right-click the updater icon and select Updater Settings to configure the Updater connection and whether to perform manual or automatic checks (see STM32CubeMXUser guide - UM1718 section 3 - for more details on Updater configuration).UM1730FAQ 5 FAQWhat is the license scheme for the STM32CubeF4 firmware?The HAL is distributed under a non-restrictive BSD (Berkeley Software Distribution) license.The Middleware stacks made by ST (USB Host and Device Libraries, STemWin) come witha licensing model allowing easy reuse, provided it runs on an ST device.The Middleware based on well-known open-source solutions (FreeRTOS, FatFs, LwIP andPolarSSL) have user-friendly license terms. For more details, refer to the license agreementof each Middleware.What boards are supported by the STM32CubeF4 firmware package?The STM32CubeF4 firmware package provides BSP drivers and ready-to-use examples forthe following STM32F4 boards: STM324x9I_EVAL, STM324xG_EVAL, STM32F4-Discovery, STM32F401-Discovery, STM32F429I-Discovery, STM32F4xx-Nucleo.Is there any link with Standard Peripheral Libraries?The STM32Cube HAL Layer is the replacement of the Standard Peripheral Library.The HAL APIs offer a higher abstraction level compared to the standard peripheral APIs.HAL focuses on peripheral common functionalities rather than hardware. The higherabstraction level allows to define a set of user friendly APIs that can be easily ported fromone product to another.Customers currently using Standard Peripheral Libraries will be helped through Migrationguides. Existing Standard Peripheral Libraries will be supported, but not recommended fornew designs.Does the HAL take benefit from interrupts or DMA? How can this becontrolled?without interrupt generation).Are any examples provided with the ready-to-use toolset projects?Yes. STM32CubeF4 provides a rich set of examples and applications (140 forSTM324x9I_EVAL). They come with the preconfigured project of several toolsets: IAR, Keiland GCC.How are the product/peripheral specific features managed?The HAL offers extended APIs, i.e. specific functions as add-ons to the common API tosupport features available on some products/lines only.How can STM32CubeMX generate code based on embedded software?STM32CubeMX has a built-in knowledge of STM32 microcontrollers, including theirperipherals and software. This enables the tool to provide a graphical representation to theuser and generate *.h/*.c files based on user configuration.DocID025922 Rev 119/22FAQ UM1730How to get regular updates on the latest STM32CubeF4 firmware releases?The STM32CubeF4 firmware package comes with an updater utility, STM32CubeUpdater,that can be configured for automatic or on-demand checks for new firmware packageupdates (new releases or/and patches).STM32CubeUpdater is integrated as well within the STM32CubeMX tool. When using thistool for STM32F4 configuration and initialization C code generation, the user can benefitfrom STM32CubeMX self-updates as well as STM32CubeF4 firmware package updates.For more details, refer to Section 4.4.20/22DocID025922 Rev 1UM1730Revision historyhistory6 RevisionTable 4. Document revision historyDate Revision Changes17-Feb-20141Initial release.DocID025922 Rev 121/22UM1730Please Read Carefully:Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice.All ST products are sold pursuant to ST’s terms and conditions of sale.Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein.No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN: (A) SAFETY CRITICAL APPLICATIONS SUCH AS LIFE SUPPORTING, ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS; (B) AERONAUTIC APPLICATIONS; (C) AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS, AND/OR (D) AEROSPACE APPLICATIONS OR ENVIRONMENTS. WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE, THE PURCHASER SHALL USE PRODUCTS AT PURCHASER’S SOLE RISK, EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE, UNLESS A PRODUCT IS EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR “AUTOMOTIVE, AUTOMOTIVE SAFETY OR MEDICAL” INDUSTRY DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS. PRODUCTS FORMALLY ESCC, QML OR JAN QUALIFIED ARE DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY.Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST.ST and the ST logo are trademarks or registered trademarks of ST in various countries.Information in this document supersedes and replaces all information previously supplied.The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.© 2014 STMicroelectronics - All rights reservedSTMicroelectronics group of companiesAustralia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America22/22DocID025922 Rev 1。

STM32CubeF4例程使用说明

STM32CubeF4例程使用说明

STM32CubeF4例程使⽤说明February 2014DocID025922 Rev 11/22UM1730User manualGetting started with STM32CubeF4 firmware packagefor STM32F4xx seriesIntroductionThe STM32Cube ? initiative was originated by STMicroelectronics to ease developers life by reducing development efforts, time and cost. STM32Cube ? covers the STM32 portfolio.STM32Cube Version 1.x includes:The STM32CubeMX, a graphical software configuration tool that allows to generate C initialization code using graphical wizards ? A comprehensive embedded software platform, delivered per series (such as STM32CubeF4 for STM32F4 series)–The STM32Cube HAL, an STM32 abstraction layer embedded software, ensuring maximized portability across the STM32 portfolio –A consistent set of middleware components such as RTOS, USB, TCP/IP and graphics –All embedded software utilities coming with a full set of examples.This user manual describes how to get started with the STM32CubeF4 firmware package. Section 1 describes the main features of STM32CubeF4 firmware, part of theSTM32Cube ? initiative.Section 2 and Section 3 provide an overview of the STM32CubeF4 architecture andfirmware package structure./doc/51b6f178cfc789eb162dc80c.htmlContents UM1730Contents1STM32CubeF4 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2STM32CubeF4 architecture overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 63STM32CubeF4 firmware package overview . . . . . . . . . . . . . . . . . . . . . . 93.1Supported STM32F4 devices and hardware . . . . . . . . . . . . . . . . . . . . . . . 93.2Firmware package overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.1How to run your first example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2How to develop your own application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.3Using STM32CubeMX for generating the initialization C code . . . . . . . . 174.4How to get STM32CubeF4 release updates . . . . . . . . . . . . . . . . . . . . . . 184.4.1How to install and run the STM32CubeUpdater program . . . . . . . . . . . 18 5FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212/22DocID025922 Rev 1UM1730List of tables List of tablesTable 1.Macros for STM32F4 series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Table 2.Evaluation and Discovery boards for STM32F4 series. . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Table 3.Number of examples available for each board. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Table 4.Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21DocID025922 Rev 13/22List of figures UM1730 List of figuresFigure 1.STM32CubeF4 firmware components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 2.STM32CubeF4 firmware architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 3.STM32CubeF4 firmware package structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 4.STM32CubeF4 examples overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4/22DocID025922 Rev 1DocID025922 Rev 15/22UM1730STM32CubeF4 main features 1 STM32CubeF4 main featuresSTM32CubeF4 gathers together, in a single package, all the generic embedded softwarecomponents required to develop an application on STM32F4 microcontrollers. In line withthe STM32Cube initiative, this set of components is highly portable, not only within theSTM32F4 series but also to other STM32 series.STM32CubeF4 is fully compatible with STM32CubeMX code generator that allows the userto generate initialization code. The package includes a low level hardware abstraction layer(HAL) that covers the microcontroller hardware, together with an extensive set of examplesrunning on STMicroelectronics boards. The HAL is available in an open-source BSD licensefor user convenience.STM32CubeF4 package also contains a set of middleware components with thecorresponding examples. They come with very permissive license terms:Full USB Host and Device stack supporting many classes.–Host Classes: HID, MSC, CDC, Audio, MTP –Device Classes: HID, MSC, CDC, Audio, DFU ?STemWin, a professional graphical stack solution available in binary format and based on the emWin solution from ST's partner Segger ?CMSIS-RTOS implementation with FreeRTOS open source solution ?FAT File system based on open source FatFS solution ?TCP/IP stack based on open source LwIP solution ?SSL/TLS secure layer based on open source PolarSSLA demonstration implementing all these middleware components is also provided in theSTM32CubeF4 package.2 STM32CubeF4 architecture overviewThe STM32CubeF4 firmware solution is built around three independent levels that caneasily interact with each other as described in the Figure 1 below:Level 0: This level is divided into three sub-layers:Board Support Package (BSP): this layer offers a set of APIs related to the hardware components on the hardware boards (Audio codec, I/O expander, Touchscreen, SRAMdriver, LCD drivers. etc…) and composed of two parts:–Component: is the driver related to the external device on the board and notrelated to the STM32, the component driver provides specific APIs to the BSPdriver’s external components and can be ported to any board.–BSP driver: it enables the component driver to be linked to a specific board and provides a set of user-friendly APIs. The API naming rule isBSP_FUNCT_Action(): ex. BSP_LED_Init(),BSP_LED_On()It's based on a modular architecture that allows it to be ported easily to any hardwareby just implementing the low level routines.Hardware Abstraction Layer (HAL): this layer provides the low level drivers and theand stacks). It provides generic, multi instance and function-oriented APIs which allowto offload the user application implementation by providing ready-to-use processes. Forexample, for the communication peripherals (I2S, UART…) it provides APIs allowing to6/22DocID025922 Rev 1initialize and configure the peripheral, manage data transfer based on polling, interrupt or DMA process, and manage communication errors that may raise duringcommunication. The HAL Drivers APIs are split in two categories, generic APIs which provides common and generic functions to all the STM32 series and extension APIs which provides specific and customized functions for a specific family or a specific part number.Basic peripheral usage examples: this layer contains examples of basic operation of the STM32F4 peripherals using only the HAL and BSP resources.Level 1: This level is divided into two sub-layers:Middleware components: a set of Libraries covering USB Host and Device Libraries, STemWin, FreeRTOS, FatFS, LwIP, and PolarSSL. Horizontal interactions between the components of this layer are done directly by calling the feature APIs while the vertical interaction with the low level drivers is done through specific callbacks and staticmacros implemented in the library system call interface. For example, the FatFsimplements the disk I/O driver to access microSD drive or the USB Mass StorageClass.The main features of each Middleware component are as follows:USB Host and Device Libraries–Several USB classes supported (Mass-Storage, HID, CDC, DFU, AUDIO, MTP)–Supports multi packet transfer features: allows sending big amounts of data without splitting them into max packet size transfers.–Uses configuration files to change the core and the library configuration without changing the library code (Read Only).–Includes 32-bit aligned data structures to handle DMA-based transfer in High-speed modes.–Supports multi USB OTG core instances from user level through configuration file (allows operation with more than one USB host/device peripheral).–RTOS and Standalone operation–The link with low-level driver is done through an abstraction layer using the configuration file to avoid any dependency between the Library and the low-levelsolution–Optimized display drivers–Software tools for code generation and bitmap editing (STemWin Builder…)FreeRTOS–Open source standard–CMSIS compatibility layer–Tickless operation during low-power mode–Integration with all STM32Cube Middleware modulesDocID025922 Rev 17/22FAT File system–FATFS FAT open source library–Long file name support–Dynamic multi-drive support–RTOS and standalone operation–Examples with microSD and USB host Mass-storage classLwIP TCP/IP stack–Open source standard–RTOS and standalone operationExamples based on the Middleware components: each Middleware component comes with one or more examples (called also Applications) showing how to use it.Integration examples that use several Middleware components are provided as well.Level 2: This level is composed of a single layer which is a global real-time and graphicaldemonstration based on the Middleware service layer, the low level abstraction layer andthe applications that make basic use of the peripherals for board-based functions.8/22DocID025922 Rev 1DocID025922 Rev 19/223STM32CubeF4 firmware package overview 3.1 Supported STM32F4 devices and hardwareSTM32Cube offers a highly portable Hardware Abstraction Layer (HAL) built around ageneric and modular architecture allowing the upper layers, Middleware and Application, toimplement its functions without in-depth knowledge of the MCU being used. This improvesthe library code re-usability and guarantees an easy portability from one device to another.The STM32CubeF4 offers full support for all STM32F4 Series devices. You only have todefine the right macro in stm32f4xx.h.Table 1 below lists which macro to define depending on the STM32F4 device you are using(this macro can also be defined in the compiler preprocessor).STM32CubeF4 features a rich set of examples and demonstrations at all levels making iteasy to understand and use any HAL driver and/or Middleware components. These Table 1. Macros for STM32F4 series Macro defined instm32f4xx.h STM32F4 devicesSTM32F405xx STM32F405RG, STM32F405VG and STM32F405ZGSTM32F415xx STM32F415RG, STM32F415VG and STM32F415ZGSTM32F407xx STM32F407VG, STM32F407VE, STM32F407ZG, STM32F407ZE,STM32F407IG and STM32F407IESTM32F417xx STM32F417VG, STM32F417VE, STM32F417ZG, STM32F417ZE,STM32F417IG and STM32F417IESTM32F427xx STM32F427VG, STM32F427VI, STM32F427ZG, STM32F427ZI,STM32F427IG and STM32F427IISTM32F437xx STM32F437VG, STM32F437VI, STM32F437ZG, STM32F437ZI,STM32F437IG and STM32F437IISTM32F429xx STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI,STM32F429BG, STM32F429BI, STM32F429NG, STM32F439NI,STM32F429IG and STM32F429IISTM32F439xx STM32F439VG, STM32F439VI, STM32F439ZG, STM32F439ZI,STM32F439BG, STM32F439BI, STM32F439NG, STM32F439NI,STM32F439IG and STM32F439IISTM32F401xC STM32F401CB, STM32F401CC, STM32F401RB, STM32F401RC,STM32F401VB and STM32F401VCSTM32F401xESTM32F401CD, STM32F401RD, STM32F401VD, STM32F401CE,STM32F401RE, STM32F401VEexamples can be run on any of the STMicroelectronics boards as listed in Table 2 below:Table 2. Evaluation and Discovery boards for STM32F4 seriesThe STM32CubeF4 firmware is able to run on any compatible hardware. This means youcan simply update the BSP drivers to port the provided examples to your own board, if it hasthe same hardware functions (LED, LCD display, pushbuttons...etc.).overview3.2 FirmwarepackageThe STM32CubeF4 firmware solution is provided in a single zip package with the structureshown in Figure 3 below.10/22DocID025922 Rev 1For each board, a set of examples are provided with preconfigured projects for EWARM, MDK-ARM and TrueSTUDIO toolchains.Figure 4 shows the project structure for the STM324xG-EVAL board. The structure is identical for other boards.The examples are classified depending on the STM32Cube level they apply to, and are named as follows: Examples in level 0 are called Examples, that use HAL drivers without any Middleware componentExamples in level 1 are called Applications, that provide typical use cases of each Middleware component Examples in level 2 are called Demonstration, that implement all the HAL, BSP and Middleware componentsA Template project is provided to allow you to quickly build any firmware application on agiven board.DocID025922 Rev 111/22All examples have the same structure,\Inc folder that contains all header files\Src folder for the sources code\EWARM, \MDK-ARM and \TrueSTUDIO folders contain the preconfigured project for each toolchain.readme.txt describing the example behavior and the environment required to make it work 12/22DocID025922 Rev 1Figure 4. STM32CubeF4 examples overviewDocID025922 Rev 113/22Table 3 provides the number of examples, applications and demonstrations available for each board.Table 3. Number of examples available for each boardBoard Examples Applications Demonstration STM324x9I_EVAL83561STM324xG_EVAL68521STM32F4-Discovery2241STM32F401-Discovery2041STM32F429I-Discovery2681STM32F4xx-Nucleo3NA NA14/22DocID025922 Rev 1UM1730Getting startedstarted4 Getting4.1 How to run your first exampleThis section explains how simple it is to run a first example with STM32CubeF4. As an illustration let's consider to run a simple LED toggling example running on the STM32F4-Discovery board:1.After downloading the STM32CubeF4 firmware package, unzip it into a directory of your choice, you just need to ensure that the package structure is not modified (as shown in Figure 3 above).2. Browse to \Projects\STM32F4-Discovery\Examples.3. Open \GPIO, then the \GPIO_EXTI folder.4. Open the project with your preferred toolchain.5. Rebuild all files and load your image into target memory.6. Run the example: each time you press User button 4, the LEDs will toggle (for more details, refer to the example readme file).You will get a quick overview of how to open, build and run an example with the supported toolchains.EWARM–Under the example folder, open the \EWARM subfolder–Open the Project.eww workspace(a)–Rebuild all files: Project->Rebuild all–Load project image: Project->Debug–Run program: Debug->Go(F5)MDK-ARM–Under the example folder, open the \MDK-ARM subfolder–Open the Project.uvproj workspace(a)–Rebuild all files: Project->Rebuild all target files–Load project image: Debug->Start/Stop Debug Session–Run program: Debug->Run (F5)TrueSTUDIO–Open the TrueSTUDIO toolchain–Click on File->Switch Workspace->Other and browse to the TrueSTUDIOworkspace directory–Click on File->Import, select General->'Existing Projects into Workspace' and then click “Next”.–Browse to the TrueSTUDIO workspace directory, select the project–Rebuild all project files: Select the project in the “Project explorer” window then click on Project->build project menu.–Run program: Run->Debug (F11)a.The workspace name may change from one example to anotherDocID025922 Rev 115/22Getting started UM17304.2 How to develop your own applicationThis section describes the required steps needed to create your own application usingSTM32CubeF4.1.Create your project: to create a new project you can either start from the Templateproject provided for each board under \Projects\\Templates or fromany available project under \Projects\\Examples orSTM32F4-Discovery).The Template project provides an empty main loop function, this is a good starting pointto allow you to get familiar with the project settings for STM32CubeF4. It has thefollowing characteristics:a) It contains sources of the HAL, CMSIS and BSP drivers which are the minimumrequired components to develop code for a given boardb) It contains the include paths for all the firmware componentsc) It defines the STM32F4 device supported, allowing to have the right configurationfor the CMSIS and HAL driversd) It provides ready-to-use user files preconfigured as follows:- HAL is initialized- SysTick ISR implemented for HAL_Delay() purpose- System clock is configured with the maximum frequency of the deviceNote:If you copy an existing project to another location, then you need to update the include paths.2. Add the necessary Middleware to your project (optional): available Middlewarestacks are: USB Host and Device Libraries, STemWin, FreeRTOS, FatFS, LwIP, andPolarSSL. To find out which source files you need to add to the project files list, refer tothe documentation provided for each Middleware, you can also have a look at theapplications available under \Projects\STM32xx_xxx\Applications\( refers to the Middleware stack, for example USB_Device) to get a betteridea of the source files to be added and the include paths.3. Configure the firmware components: the HAL and Middleware components offer a set of build time configuration options using macros declared with “#define” in a header file. A template configuration file is provided within each component, which you have to copy to the project folder (usually the configuration file is named xxx_conf_template.h. The word “_template” needs to be removed when copying it to the project folder). The configuration file provides enough information to know the effect of each configuration option. More detailed information is available in the documentation provided for each component.4. Start the HAL Library: after jumping to the main program, the application code needsUM1730Getting started5. Configure the system clock: the system clock configuration is done by calling these two APIsa) HAL_RCC_OscConfig(): configures the internal and/or external oscillators, PLL source and factors. You can choose to configure one oscillator or all oscillators.You can also skip the PLL configuration if there is no need to run the system athigh frequencyb) HAL_RCC_ClockConfig(): configures the system clock source, Flash latency and AHB and APB prescalers6. Develop your application process: at this stage, your system is ready and you can start developing your application code.a) The HAL provides intuitive and ready-to-use APIs for configuring the peripheral, and supports polling, interrupt and DMA programming models, to accommodateany application requirements. For more details on how to use each peripheral,refer to the rich examples set provided.b) If your application has some real-time constraints, you can find a large set of examples showing how to use FreeRTOS and integrate it with all Middlewarestacks provided in STM32CubeF4, it can be a good starting point for yourdevelopment.c) IMPORTANT NOTE: care must be taken when using HAL_Delay(). This functionprovides an accurate delay (in milliseconds) based on a variable incremented inSysTick ISR. This implies that if HAL_Dely() is called from a peripheral ISRprocess, then the SysTick interrupt must have the highest priority (numericallylower) than the peripheral interrupt. Otherwise the caller ISR process will beblocked. To change the SysTick interrupt priority, you have to use theHAL_NVIC_SetPriority() function.4.3 Using STM32CubeMX for generating the initialization C codeAnother alternative to Steps 1 to 5 described in Section 4.2 consists in using theSTM32CubeMX tool to easily generate code for the initialization of the system, theperipherals and middleware (Steps 1 to 5 above) through a step-by-step process:Selection of the STMicroelectronics STM32 microcontroller that matches the required set of peripherals. Configuration of each required embedded software thanks to a pinout-conflict solver, a clock-tree setting helper, a power consumption calculator, and an utility performingMCU peripheral configuration (GPIO, USART...) and middleware stacks (USB,TCP/IP...).Generation of the initialization C code based on the configuration selected. This code is ready to be used within several development environments. The user code is kept atthe next code generation.For more information, please refer to UM1718.DocID025922 Rev 117/22Getting started UM173018/22DocID025922 Rev 14.4 How to get STM32CubeF4 release updatesThe STM32CubeF4 firmware package comes with an updater utility: STM32CubeUpdater,also available as a menu within STM32CubeMX code generation tool.The updater solution detects new firmware releases and patches available from/doc/51b6f178cfc789eb162dc80c.html andproposes to download them to the user’s computer.4.4.1 How to install and run the STM32CubeUpdater programDouble-click SetupSTM32CubeUpdater.exe file to launch the installation.?Accept the license terms and follow the different installation steps.Upon successful installation, STM32CubeUpdater becomes available as an STMicroelectronics program under Program Files and is automatically launched.The STM32CubeUpdater icon appears in the system tray:Right-click the updater icon and select Updater Settings to configure the Updater connection and whether to performmanual or automatic checks (see STM32CubeMXUser guide - UM1718 section 3 - for more details on Updater configuration).UM1730FAQ 5 FAQWhat is the license scheme for the STM32CubeF4 firmware?The HAL is distributed under a non-restrictive BSD (Berkeley Software Distribution) license. The Middleware stacks made by ST (USB Host and Device Libraries, STemWin) come with a licensing model allowing easy reuse, provided it runs on an ST device.The Middleware based on well-known open-source solutions (FreeRTOS, FatFs, LwIP and PolarSSL) have user-friendly license terms. For more details, refer to the license agreement of each Middleware.What boards are supported by the STM32CubeF4 firmware package?The STM32CubeF4 firmware package provides BSP drivers and ready-to-use examples for the following STM32F4 boards: STM324x9I_EVAL, STM324xG_EVAL, STM32F4-Discovery, STM32F401-Discovery, STM32F429I-Discovery, STM32F4xx-Nucleo.Is there any link with Standard Peripheral Libraries?The STM32Cube HAL Layer is the replacement of the Standard Peripheral Library.The HAL APIs offer a higher abstraction level compared to the standard peripheral APIs. HAL focuses on peripheral common functionalities rather than hardware. The higher abstraction level allows to define a set of user friendly APIs that can be easily ported from one product to another.Customers currently using Standard Peripheral Libraries will be helped through Migration guides. Existing Standard Peripheral Libraries will be supported, but not recommended for new designs.Does the HAL take benefit from interrupts or DMA? How can this becontrolled?without interrupt generation).Are any examples provided with the ready-to-use toolset projects?Yes. STM32CubeF4 provides a rich set of examples and applications (140 forSTM324x9I_EVAL). They come with the preconfigured project of several toolsets: IAR, Keil and GCC.How are the product/peripheral specific features managed?The HAL offers extended APIs, i.e. specific functions as add-ons to the common API to support features available on some products/lines only.How can STM32CubeMX generate code based on embedded software?STM32CubeMX has a built-in knowledge of STM32 microcontrollers, including theirperipherals and software. This enables the tool to provide a graphical representation to the user and generate *.h/*.c files based on user configuration.DocID025922 Rev 119/22。

STM32CubeF4使用入门

STM32CubeF4使用入门

UM1730STM32CubeF4使用入门山西大学电子信息工程系王晓峰Wangxiaofeng@引言STMCube是由意法半导体原创倡议,旨在通过减少开发负担,时间和费用来为开发者提供轻松的开发体验。

STMCube覆盖了STM32全系列。

STM32Cube版本1.x包括:1、STM32CubeMX,一个图形软件配置工具,允许通过图形化向导来生成C初始化代码。

2、一个广泛的嵌入式软件平台,按照产品系列提供(例如STM32CubeF4对应STM32F4系列)。

此平台包括STM32Cube HAL(一个STM32的硬件抽象层,确保STM32之间最大的可移植性),再加上配套的中间件(RTOS,USB,TCP/IP和图形)。

所有嵌入式软件组件都提供完整的例程。

本用户手册描述了如何开始使用STM32CubeF4固件包。

第一部分,描述了STM32CubeF4固件包的主要特性,STMCube的首创倡议。

第二部分和第三部分提供了一个STM32CubeF4架构概览和固件包结构。

1STM32CubeF4主要特性STM32CubeF4集合了所有开发STM32F4应用嵌入式软件组件。

依照STMCube倡议,这些组件具有高度的可移植性,不止在STM32F4系列中,也包括所有STM32系列。

STM32CubeF4高度兼容STM32CubeMX,STM32CubeMX允许用户生成初始化代码。

包内包括一个底层硬件抽象层(HAL),HAL覆盖了微控制器硬件,集成了广泛的例程,可运行在意法半导体的开发板上。

为了用户便利,硬件抽象层为开源BSD许可协议。

STM32CubeF4包含了一套中间件组件,带有对应的例程。

它们具有非常自由的许可证条款:1、CMSIS-RTOS贯彻了FreeRTOS的开源解决方案2、TCP/IP协议栈基于开源的LwIP解决方案3、FAT文件系统基于开源的FatFs解决方案,支持NAND闪存访问4、完整的USB主从设备协议栈支持。

STM32F4 UCOS开发手册

STM32F4 UCOS开发手册
图 1.2.4 PORT 文件夹内容
6
UCOS 开发手册
ALIENTEK 探索者 UCOSII/III 开发教程
4、将所有文件添加到工程中 我们前面只是将所有的文件添加到工程目录的文件夹里面,还没有将这些文件真正的添加 到工程中,我们在工程分组中建立三个分组:UCOSII-CORE、UCOSII-PORT 和 UCOSII-CONFIG。 建立完成后如图 1.2.5 所示。
图 1.2.6 添加完成后的工程
7
STM32F4 UCOS 开发手册
图 1.2.3 CONFIG 文件夹内容 4、向 PORT 文件夹中添加文件 我们需要向 PORT 文件夹中添加 5 个文件:os_cpu.h、os_cpu_a.asm、os_cpu_c.c、os_dbg.c 和 os_dgb_r.c。这五个文件可以从本实验的 PORT 文件夹中拷贝到自己的 PORT 文件夹中,拷 贝完成后如图 1.2.4 所示。
图 1.1.2 UCOS II 源码文件。
4
STM32F4 UCOS 开发手册
ALIENTEK 探索者 UCOSII/III 开发教程
图 1.1.2 中 Doc 文件夹下面是一些关于 UCOS II 的文档,Source 文件夹就是 UCOS II 的源 码。
1.2 UCOS II 移植
1) 向工程中添加相应文件 1、建立相应文件夹 我们在工程目录下新建 UCOSII 文件夹,并在 UCOSII 文件夹另外中新建三个文件夹: CONFIG、CORE 和 PORT,如图 1.2.1 所示。
图 1.2.1 新建 UCOSII 文件夹及其内部文件夹 2、向 CORE 文件夹中添加文件 在 CORE 文件夹中我们添加 UCOSII 源码,我们打开 UCOSII 源码的 Source 文件夹,里面 一共有 14 个文件,除了 os_cfg_r.h 和 os_dbg_r.c 这两个文件外我们将其他的文件都复制到我们 工程中 UCOSII 文件夹下的 CORE 文件中,如图 1.2.2 所示。

STM32F4

STM32F4

STM32F4TFT-LCD一、简介:TFT-LCD即薄膜晶体管液晶显示器,依据其尺寸、分辨率和驱动芯片的不同有很多分类,下边会依据2.8寸320X240分辨率以ILI9341芯片驱动的TFT-LCD做相关介绍。

二、接口:模块采用16位并方式与外部连接,其相关接口图及信号线功能如下:CS:TFTLCD片选信号。

WR:向TFTLCD写数据。

RD:从TFTLCD读取数据。

D[15:0]:16位数据线。

RS:命令/数据标示(0,读写命令;1,读写数据)。

三、驱动时序:对于写时序:CS拉低做片选,RS表示是要写数据还是要写命令,在WR信号线的上升沿获取数据线D[0:15]上的数据,在写时序上RD 信号线总是处于高电平。

对于读时序同理。

四、驱动流程:对于LCD的驱动流程可由下图表示:首先通过LCD_RST引脚做复位,再进行初始化序列,由于本人现阶段水平有限,先不去研究相关初始化序列,所以就直接运用LCD商家给出的初始化序列代码。

无论是读写指令,都需要设置好坐标,再做出读写GRAM的相关指令。

在随后涉及到颜色数据的相关处理,下边就针对颜色数据做一下相关说明。

对于颜色的设定也有多种格式,在这里只是针对RGB565颜色格式做说明。

RGB565这样看(Red)[5位](Green)[6位](Blue)[5位],组成16位颜色深度。

五、指令:对于ILI9341的指令有很多,下边对ILI9341驱动芯片的个别指令做相关说明:1、0XD3:该指令用于读取芯片ID。

由此可以依据不同的LCD做相关初始化,做到更好的兼容。

2、OX36:存储器访问控制指令,可以在读写数据过程中控制GRAM指针的增长方向,简单说明就是控制像素的扫描方式。

3、0X2A:用于设置列地址,也就是在从左到右从上到下的扫描方式下,设置x坐标。

即用于设置x坐标的范围。

4、0X2B:与OX2A类似,该指令用于设置y坐标。

需要说明的是在OX2A和OX2B的控制下就可以在屏幕上开窗显示了。

STM32F4 EMWIN开发手册介绍

STM32F4 EMWIN开发手册介绍

图 1.1.1 STM32F4xx 库下载 下载解压后打开 Libraries 文件,打开后如图 1.1.2 所示,里面包含有 STM32F4xx 的标准外 设库和 DSP 库,DSP 库在 CMSIS 文件中,我们将 CMSIS 复制到我们基础工程的 FWLIB 文件 中。CMSIS 文件大概有 133M,里面包含有一些我们用不到的文件,而我们只用到 DSP 库,所 以在这里将这些不用的文件删除,最终只留下 Include 和 Lib 这两个文件。Include 为头文件, Lib 为针对不同的编译环境而做的 DSP 库,有 ARM,G++,GCC。因为我们使用的是 KEIL 所 以只留 ARM 这个文件,其他两个也删除掉,如果使用的是 IAR 就保留 GCC 这个文件。
333121886alientek探索者stemwin开发教程stm32f4emwin开发手册目录第一章stemwin无操作系统移植11移植准备工作12向工程添加文件13修改工程文件14触摸屏移植1215综合测试程序编写1716下载验证19第二章stemwin带操作系统移植2021移植准备工作2122向工程添加以及修改相应文件2123编写综合测试程序2424下载验证24alientek探索者stemwin开发教程stm32f4emwin开发手册第一章stemwin无操作系统移植我们在使用m3内核mcu的时候会移植ucgui来制作精美的uiucgui的高级版本就是emwin而stemwin是segger授权给st的emwin版本st的芯片可以免费使用stemwin而且stemwin针对st的芯片做了优化
图 1.1.3 设置 FPU 从图 1.1.3 中我们可以看出如果要使用 FPU 的话__FPU_PRESENT 和__FPU_USED 要为 1, 根据 arm_math.h 中的要求, 如果要使用 DSP 库的话还要定义 ARM_MATH_CM4 和__CC_ARM, 因此我们按图 1.1.4 所示添加__FPU_PRESENT,__FPU_USED,ARM_MATH_CM4 和 __CC_ARM 的定义。

STM32F4_新建Keil工程

STM32F4_新建Keil工程
6.1.在 Project 目录中,选择 Options for Target1 显示目标板 配置文件对话框。
6.2.打开 Target 标签,按如下图 6.2 所示配置 图 6.2 Target 标签配置
6.3 打开 Debug 标签,按以下步骤进行 图 6.3.1 Debug 标签设置
图 6.3.2 点击 Setting 按钮,进入 Cortex-M Target Driver Setup 设置界面
如图 2.设备选择对话框
3.点击是(Y)按键复制并保存 STM32 启动代码到工程文件夹中 图 3.是否选择启动代码对话框
4.接着我们创建一个新文件,在 File 目录中,选择 New...打开 一个空的编辑窗口。点击 File 中 Save As...保存到该工程文件夹下 并重新命名为 Bilnky.c。
STM32F4 Discovery——新建工程 1.我们首先打开 Keil(我装的是 V4.53 版本的,可在此下载),在 Project 目录中,选择 New uVision Project...显示创建工程对话框, 我们把它保存在不含中文的文件夹中,命名工程并保存。 如图 1.创建工程
2. 当 保 存 后 , 弹 出 设 备 选 择 对 话 框 , 我 们 双 击 STMicroelectronics,往下选择 STM32F407VG 设备并点击 OK 保存你 的设置。
/*配置 PD12 为输出、上拉模式 */ 5. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; 6.GPIO_Init(GPIOD, &GPIO_InitStructure);//GPIOD 初始化

STM32F4_DISCOVERY(中文)

STM32F4_DISCOVERY(中文)

UM1472用户手册STM32F4DISCOVERYSTM32F4高性能探索板简介STM32F4DISCOVERY帮助你探索发现STM32F4的高性能特性,并帮助你开发应用。

STM32F4DISCOVERY基于STM32F407VGT6芯片,包括一个板载的有嵌入式调试工具接口的ST-LINK/V2,ST MEMS数字加速器,ST MEMS 数字麦克风,音频DAC集成了class D扬声器驱动器,LED灯,按钮和一个USB OTG的micro-AB连接器。

图 1 STM32F4DISCOVERYSTM32F4DISCOVERY系统要求目录1 约定 (5)2 快速入门 (6)开始 (6)2.1 系统要求 (7)2.2 支持STM32F4DISCOVERY的开发工具链 (7)2.3 订单编码 (7)3 特性 (7)4 硬件和布局 (8)4.1 STM32F407VGT6微控制器 (10)4.2 嵌入的ST-LINK/V2 (13)4.2.1 使用ST-LINK/V2编程/调试板上STM32F4 (14)4.2.2 使用ST-LINK/V2编程/调试外部STM32应用 (15)4.3 电源和电源选择 (16)4.4 LED (16)4.5 按键 (16)4.6 板上音频功能 (17)4.7 支持USB OTG (17)4.8 运动传感器(ST MEMS LIS302DL) (17)4.9 JP1 (Idd) (17)4.10 锡桥 (18)4.11 扩展连接 (19)5 机械制图 (29)6 电气原理图 (31)- 2 -电气原理图STM32F4DISCOVERY 表列表 1 ON/OFF 约定 (5)表 2 跳线状态 (13)表 3 调试连接器CN2 (SWD) (15)表 4 锡桥 (18)表 5 MCU引脚描述对应板子功能 (19)- 3 -STM32F4DISCOVERY系统要求图列图 1 STM32F4DISCOVERY (2)图 2 硬件框图 (9)图 3 顶层布局 (9)图 4 底层布局 (10)图 5 STM32F407VGT6封装 (10)图 6 STM32F407VGT6框图 (12)图 7 典型配置 (13)图 8 STM32F4DISCOVERY连接图 (14)图 9 ST-LINK连接图 (15)图 10 STM32F4DISCOVERY机械制图 (29)图 11 STM32F4DISCOVERY (31)图 12 ST-LPINK/V2(SWD only) (32)图 13 MCU (33)图 14 Audio (34)图 15 USB_OTG_FS (35)图 16 Peripherals (36)- 4 -电气原理图STM32F4DISCOVERY 1 约定表1提供了在本文中使用的一些约定的定义表 1 ON/OFF 约定- 5 -STM32F4DISCOVERY系统要求2 快速入门STM32F4DISCOVERY是一个低成本、易于使用的开发套件,快速评估并开始使用STM32F4高性能微控制器的进行开发。

STM32F4xxx 参考手册学习摘录

STM32F4xxx 参考手册学习摘录

2存储器和总线架构64 KB CCM(内核耦合存储器)数据RAM 不属于总线矩阵,只能通过CPU 对其进行访问。

对APB 寄存器执行16 位或8 位访问时,该访问将转换为32 位访问:总线桥将16 位或8 位数据复制后提供给32 位向量。

存储器组织结构程序存储器、数据存储器、寄存器和I/O 端口排列在同一个顺序的 4 GB 地址空间内。

各字节按小端格式在存储器中编码。

字中编号最低的字节被视为该字的最低有效字节,而编号最高的字节被视为最高有效字节。

嵌入式SRAMSTM32F405xx/07xx 和STM32F415xx/17xx 带有4 KB 备份SRAM(请参见第5.1.2 节:电池备份域)和192 KB 系统SRAM系统SRAM 分为三个块:●映射在地址0x2000 0000 的112 KB 和16 KB 块●映射在地址0x2002 0000 的64 KB 块,(适用于STM32F42xxx 和STM32F43xxx)。

AHB 主总线支持并发SRAM 访问(通过以太网或USB OTG HS):例如,当CPU 对112 KB 或64 KB SRAM 进行读/写操作时,以太网MAC 可以同时对16 KB SRAM 进行读/写操作。

●在地址0x1000 0000 映射的64 KB 块,只能供CPU 通过数据总线访问。

位段Cortex™-M4F 存储器映射包括两个位段区域。

这些区域将存储器别名区域中的每个字映射到存储器位段区域中的相应位。

在别名区域写入字时,相当于对位段区域的目标位执行读-修改-写操作。

bit_word_addr = bit_band_base + (byte_offset x 32) + (bit_number × 4)BOOT0 为专用引脚,而BOOT1 则与GPIO 引脚共用。

一旦完成对BOOT1 的采样,相应GPIO 引脚即进入空闲状态,可用于其它用途。

器件退出待机模式时,还会对BOOT 引脚重新采样。

1-STM32F4xx中文参考手册2(DMA2D+LTDC+SAI+FMC)

1-STM32F4xx中文参考手册2(DMA2D+LTDC+SAI+FMC)

11 Chrom-Art控制器 (DMA2D)Accelerator™本章适用于 STM32F42xxx 和 STM32F43xxx 系列。

简介11.1 DMA2DChrom-Art Accelerator™ (DMA2D) 是专用于图像处理的专业 DMA。

它可以执行下列操作:∙用特定颜色填充目标图像的一部分或全部∙将源图像的一部分(或全部)复制到目标图像的一部分(或全部)中∙通过像素格式转换将源图像的一部分(或全部)复制到目标图像的一部分(或全部)中∙将像素格式不同的两个源图像部分和/或全部混合,再将结果复制到颜色格式不同的部分或整个目标图像中。

在索引颜色模式或直接颜色模式下,支持所有经典颜色编码方案,并支持每像素 4 位到最高32 位。

DMA2D 自身具有专门的 CLUT(颜色查找表)存储器。

的主要特性11.2 DMA2DDMA2D 的主要特性有:∙采用单 AHB 主设备总线架构。

∙AHB 从设备编程接口支持 8/16/32 位访问(32 位的 CLUT 访问除外)。

∙用户可编程工作区大小∙用户可编程源区域和目标区域的偏移∙用户可编程整个存储空间的源地址和目标地址∙最多支持 2 个源的混合操作∙Alpha 值可修改(源值、固定值或调制的值)∙用户可编程源颜色格式和目标的颜色格式∙采用间接或直接颜色编码时,支持多达 11 种颜色格式,且支持每像素 4 位到最高 32 位∙间接颜色模式下使用 2 个内部存储器存储 CLUT∙通过 CPU 自动加载 CLUT 或对 CLUT 进行编程∙用户可编程 CLUT 大小∙使用内部定时器控制 AHB 带宽∙支持 4 种工作模式:寄存器到存储器、存储器到存储器、存储器到存储器且支持像素格 式转换和存储器到存储器且支持像素格式转换和混合∙可使用固定颜色进行区域填充∙可从一个区域复制到另一个区域∙在源图像和目标图像之间进行复制时进行像素格式转换∙支持从颜色格式不同的两幅源图像复制并混合∙可中止并挂起 DMA2D 操作∙支持在传输用户可编程的目标行时生成水印中断∙支持发生总线错误或访问冲突时生成中断∙支持处理完成时生成中断336/1710文档 ID 018909 第 7 版功能说明11.3 DMA2D11.3.1 概述DMA2D 控制器执行直接存储器传输。

STM32F401RE开发板使用指南说明书

STM32F401RE开发板使用指南说明书

Design tipMotionFX orientation estimationquick guideAndrea VitaliPurpose and benefitsThis design note explains how to configure and use the osxMotionFX software library andincludes:∙Hints for a fast startup when proper shutdown sequence is implemented by saving thresholds and calibration parameters for the gyroscope and the magnetometer ∙Guide to accurate gyroscope calibration in static and dynamic conditions, including discussion on how a static condition can be automatically identified∙Guide to accurate magnetometer calibration, including discussion on how to track a varying magnetic environment and how to get convergence to true yaw in staticconditions and control speed of convergence in dynamic conditions∙Guide to accelerometer use, including discussion on how to control speed ofconvergence in static and dynamic conditions∙Explanation of format and orientation conventions for inputs and outputsConfiguring MotionFX: control knobsFloat ATime: 0.5 to 10; if it is low, accelerometer is trusted more in the update phase(see below) in static condition (no motion); it is convenient to set it to a high value ifaccelerometer is considered unreliable because there are large offset and gain errors.Float MTime: 0.5 to 10; if it is low, magnetometer is trusted more in the update phase(see below) in dynamic condition; it is convenient to set it to a high value if magnetometeris unreliable because of magnetic anomalies or imperfect hard/soft iron compensation. Inthe static condition, the magnetometer is not trusted.Float FrTime: 0.5 to 10; if it is low, accelerometer is trusted more in the update phase(see below) in dynamic condition (high-g motion); it is convenient to set it to high value toreduce the effect of high-g motion, or if the accelerometer is considered unreliable.Unsigned char LMode: specify gyroscope calibration.∙LMode=0, gyro bias calibration is not active∙LMode=1, gyro bias calibration is active in static condition (more accurate); static condition is identified as explained below.∙LMode=2, gyro bias calibration is active in dynamic condition (less accurate)Float gbias_mag_th_sc_6X,gbias_acc_th_sc_6X,bias_gyro_th_sc_6X: ifhigh-pass filtered output from mag/acc/gyro is below threshold, then a static condition isidentified; thresholds for 6X data fusion (acc+gyro)Float gbias_mag_th_sc_9X,gbias_acc_th_sc_9X,gbias_gyro_th_sc_9X: i fhigh-pass filtered output from mag/acc/gyro is below threshold, then a static condition isidentified; thresholds for 9X data fusion (acc+gyro+mag)Unsigned char modx: down sampling factor to reduce computational complexity;osx_MotionFX_propagate() needs to be always executed in order to estimateorientation based on previous estimate and internal state; osx_MotionFX_update() canbe executed always (modx=1) or less frequently (modx>1) to correct the estimate withinformation from sensors.Int start_automatic_gbias_calculation: set to 1 to start automatic computationof aforementioned thresholds; automatically reset to 0 when computation is completed;sensors needs to be kept static when computation is ongoing.Using MotionFX: pseudo-code sequenceInitialization (to be done once)1. Init sensors (acc and gyro for 6X fusion, also mag for 9X fusion); on power-on waitfor transients to be completed in order to get good data samples2. Init MotionFX fusion: osx_MotionFX_initialize()3. Init mag calibration: osx_MotionFX_compass_Init()4. osx_MotionFX_getKnobs(); modify settings; _setKnobs()5. Reset by disabling fusion: osx_MotionFX_enable_6X(0) / _9X(0)Start fusion1. Init gyro calibration if possible: osx_MotionFX_setGbias()2. Init mag calib if possible: osx_MotionFX_compass_setCalibrationData()3. Enable data fusion: osx_MotionFX_enable_6X(1) / _9X(1)Data fusion (must be always executed at each iteration)1. Read input data from accelerometer and gyroscope for 6X fusion2. Read input data also from magnetometer for 9X fusion3. Compensate mag hard/soft iron effects (e.g. compensate hard iron by subtractingoffsets read when mag calibration is completed, see below)4. Set input: acc in G, gyro in DPS (deg per second), mag in uT/50 (microtesla/50)5. Set correct delta time: e.g. if 100Hz, then dt = 0.01msec6. Call osx_MotionFX_propagate()7. Call osx_MotionFX_update(); increase speed by setting modx>1 in controlknobs, this will cause the function to be effectively executed only once every modxcalls8. Get output: Euler angles (roll, pitch, yaw), quaternion, gravity, residual linearacceleration, heading to magnetic NorthMag calibration (can be executed less frequently, at some iteration)1. If not started: osx_MotionFX_compass_forceReCalibration()2. Set input: acc in mG (milli-g), mag in mGauss (milli-Gauss)3. Call osx_MotionFX_compass_saveAcc()4. Call osx_MotionFX_compass_saveMag()5. Call osx_MotionFX_compass_run(), this effectively runs the calibration6. If osx_MotionFX_compass_isCalibrated() becomes true, and periodically:a. osx_MotionFX_getCalibrationData()and save for compensation aboveb. for immediate convergence to true yaw: reset fusion by disable/enable; notethat convergence to true yaw is allowed only in dynamic condition, because instatic condition the magnetometer is not trustedStop fusiona. Save gyro calibration for later use: osx_MotionFX_getGbias()b. Save mag calibration for later use: osx_MotionFX_getCalibrationData()c. Disable osx_MotionFX_enable_6X(0) / _9X(0)MotionFX magnetometer calibrationMagnetometer calibration is running only if osx_MotionFX_compass_SaveAcc() and_SaveMag() functions are called in the main loop.Calibration is started by osx_MotionFX_forceReCalibration(). Completion status ischecked by osx_MotionFX_compass_isCalibrated().After completion, calibration parameters can be read and used to compensate hard/softiron effects in magnetometer data before they are fed to orientation estimation functionsosx_MotionFX_propagate() and _update(). In the current version of the library, onlyoffsets are estimated, hence only hard iron effects can be compensated.Even after completion, if _SaveAcc() and _SaveMag() are called, calibration continuesto run in the background and may update the calibration parameters; this is why calibrationparameters should be read periodically even after completion, so that any update can becaptured and exploited.In the current version of the library, magnetic anomalies are not rejected, but they arefiltered out. If there is a limited amount of anomalies with respect to good data, accuracy ofcalibration is minimally affected. In some case, it can also happen that the anomalies’effects do cancel each other out.MotionFX input/output conventionsInput is coming from 3-axis sensors: accelerometer, gyroscope and magnetometer. Theorientation of sensors is specified by a three-letter code, one for each axis.Letters (NSWEUD) indicate where axes (XYZ) are pointing. First letter for X, second letterfor Y, third letter for Z. In figure 1, there are four examples: NED, ENU, SEU and NWUsystem/sensor orientation (left). The specific configuration for sensors on IKS01A1 NucleoeXpansion board is also shown (right).Output is the orientation in different formats: Quaternion and Euler angles. Output isreferenced to a coordinate system specified by a three-letter code.Quaternions are arrays of 4 values, Q = [X, Y, Z, W]. When processing quaternions, it isimportant to remember that they are a redundant representation of orientation. Q isequivalent to –Q. As an example: averaging Q and –Q should not give zero as output, butQ or –Q.Euler angles in the NED system, where XYZ axes are North-East-Down, are as follows:•Roll, also known as bank, is a clockwise rotation around X looking to North•Pitch, also known as attitude, is a clockwise rotation around Y looking to East•Yaw, also known as heading, is a rotation around Z looking DownFigure 1. Sensor orientation: NED, ENU, SEU, NWU. Sensor orientation in IKS01A1 NucleoeXpansion board.Figure 2. Euler angles in North-East-Down coordinate system.Support materialUpDownNorthEastWest SouthX NorthY East Z Down XYZNED systemXYZ ENU system Y North X EastZ Up XYZ SEU system Y East X South Z Up XYZ NWU system X North Y West Z UpRevision historyIMPORTANT NOTICE – PLEASE READ CAREFULLYSTMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers’ products.No license, express or implied, to any intellectual property right is granted by ST herein.Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces information previously supplied in any prior versions of this document.© 2017 STMicroelectronics – All rights reserved。

STM32F4xx FPU的设置

STM32F4xx FPU的设置
在 arm_math 的开头部分是有这些编译控制信息: #ifndef _ARM_MATH_H #define _ARM_MATH_H
#define __CMSIS_GENERIC
/* disable NVIC and Systick functions */
#if defined (ARM_MATH_CM4) #include "core_cm4.h"
中。通过对 256 点三角函数表的查询和插值算法得到任意角度的精确函数值,这就比“原装”的 sin()、cos()
快多了。
当然有些例外的是开发函数 sqrt(),在 arm_math.h 中是这么定义的:
static __INLINE arm_status arm_sqrt_f32(float32_t in, float32_t *pOut)
1.编译控制选项:虽然 STM32F4XX 固件库的例程之 system_stm32f4XXX.c 文件中添加了对应的代 码,但给用户评估使用的 STM32F4-Discovery 例程中却没有,因此 MDK4.23 编写浮点运算程序时,虽然 编译器正确产生了 V 指令来进行浮点运算,但是因为 system_stm32f4XXX.c 文件没有启用 FPU,因此 CPU 执行时只认为是遇到非法指令而跳转到 HardFault_Handler()中断中原地踏步。因此要保证这个错误不发生, 必须要在 system_init()函数里面添加如下代码: /* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */

STM32F4 EMWIN开发手册介绍

STM32F4 EMWIN开发手册介绍

2
STM32F4 EMWIN 开发手册
ALIENTEK 探索者 STemWin 开发教程
第一章 STemWin 无操作系统移植
我们在使用 M3 内核 MCU 的时候会移植 UCGUI 来制作精美的 UI,UCGUI 的高级版本就 是 emWin, 而 STemWin 是 SEGGER 授权给 ST 的 emWin 版本, ST 的芯片可以免费使用 STemWin, 而且 STemWin 针对 ST 的芯片做了优化。本章我们将向大家介绍如何在 STM32F407 开发板上 移植 STemWin,在本章的移植过程中适配我们公司的 2.8 寸,3.5 寸,4.3 寸这三种不同尺寸的 屏幕。本章分为如下几个部分: 1.1 移植准备工作 1.2 向工程添加文件 1.3 修改工程文件 1.4 触摸屏移植 1.5 综合测试程序编写 1.6 下载验证
STM32F4 EMWIN 开发手册
ALIENTEK 探索者 STemWin 开发教程
EMWIN 开发手册
V1.0
−ALIENTEK STM32F4 EMWIN 开发教程
官方店铺: 技术论坛: 技术交流群: 333121886
第二章 STemWin 带操作系统移植 ............................................... 20
2.1 移植准备工作 .................................................................................................... 21 2.2 向工程添加以及修改相应文件 ......................................................................... 21 2.3 编写综合测试程序 ............................................................................................ 24 2.4 下载验证 ...........................................................................................ቤተ መጻሕፍቲ ባይዱ................ 24
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

January 2014DocID022256 Rev 41/42IntroductionThe STM32F4DISCOVERY helps you to discover the STM32F407 & STM32F417 lines’ high-performance features and to develop your applications.It is based on an STM32F407VGT6 and includes an ST-LINK/V2 embedded debug tool interface, ST MEMS digital accelerometer, ST MEMS digital microphone, audio DAC with integrated class D speaker driver, LEDs, pushbuttons and a USB OTG micro-AB connector.1.Picture not contractualContents UM1472Contents1Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Quick start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.1Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3Development toolchain supporting the STM32F4DISCOVERY . . . . . . . . . 62.4Order code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74Hardware and layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.1STM32F407VGT6 microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.2Embedded ST-LINK/V2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2.1Using ST-LINK/V2 to program/debug the STM32F4 on board . . . . . . .144.2.2Using ST-LINK/V2 to program/debug an external STM32 application . .154.3Power supply and power selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.4LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.5Pushbuttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.6On board audio capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.7USB OTG supported . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.8Motion sensor (ST MEMS LIS302DL or LIS3DSH) . . . . . . . . . . . . . . . . . 174.9JP1 (Idd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.10OSC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.10.1OSC clock supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194.10.2OSC 32KHz clock supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194.11Solder bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.12Extension connectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 5Mechanical drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 6Electrical schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41UM1472List of tables List of tablesTable 1.ON/OFF conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Table 2.Jumper states. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Table 3.Debug connector CN2 (SWD). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 Table 4.Solder bridges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Table 5.MCU pin description versus board function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Table 6.Document revision history. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41List of figures UM1472 List of figuresFigure 1.STM32F4DISCOVERY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Figure 2.Hardware block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Figure 3.Top layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 Figure 4.Bottom layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 Figure 5.STM32F407VGT6 package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Figure 6.STM32F407VGT6 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12 Figure 7.Typical configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Figure 8.STM32F4DISCOVERY connections image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 Figure 9.ST-Link connections image. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 Figure 10.STM32F4DISCOVERY mechanical drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 Figure 11.STM32F4DISCOVERY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 Figure 12.ST-LINK/V2 (SWD only). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 Figure 13.MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 Figure 14.Audio. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 Figure B_OTG_FS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 Figure 16.Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40UM1472Conventions 1 ConventionsTable1 provides the definition of some conventions used in the present document.Quick start UM14722 Quick startThe STM32F4DISCOVERY is a low-cost and easy-to-use development kit to quicklyevaluate and start a development with an STM32F4 high-performance microcontroller.Before installing and using the product, please accept the Evaluation Product License Agreement from /stm32f4-discovery.For more information on the STM32F4DISCOVERY and for demonstration software, visit /stm32f4-discovery.2.1 Getting startedFollow the sequence below to configure the STM32F4DISCOVERY board and launch theDISCOVER application:1.Check jumper position on the board, JP1 on, CN3 on (DISCOVERY selected).2. Connect the STM32F4DISCOVERY board to a PC with a USB cable ‘type A to mini-B’through USB connector CN1 to power the board. Red LED LD2 (PWR) then lights up.3. Four LEDs between B1 and B2 buttons are blinking.4. Press user button B1 to enable the ST MEMS sensor, move the board and observe thefour LEDs blinking according to the motion direction and speed. (If you connect asecond USB cable ‘type A to micro-B’ between PC and CN5 connector then the board is recognized as standard mouse and its motion will also control the PC cursor).5. To study or modify the DISCOVER project related to this demo, visit/stm32f4-discovery and follow the tutorial.6. Discover the STM32F4 features, download and execute programs proposed in the listof projects.7. Develop your own application using available examples.2.2 System requirements•Windows PC (XP , Vista, 7)•USB type A to Mini-B USB cable2.3 Development toolchain supporting the STM32F4DISCOVERY•Altium, TASKING™ VX-Toolset •Atollic TrueSTUDIO ®•IAR Embedded Workbench ® for ARM (EWARM) •Keil™, MDK-ARM2.4 Order codeTo order the STM32F4 high-performance discovery board, use the order codeSTM32F4DISCOVERY .UM1472Features 3 FeaturesThe STM32F4DISCOVERY offers the following features:•STM32F407VGT6 microcontroller featuring 1MB of Flash memory, 192 KB of RAM in an LQFP100 package•On-board ST-LINK/V2 with selection mode switch to use the kit as a standalone ST-LINK/V2 (with SWD connector for programming and debugging)•Board power supply: through USB bus or from an external 5V supply voltage•External application power supply: 3V and 5V•LIS302DL or LIS3DSH, ST MEMS motion sensor, 3-axis digital output accelerometer•MP45DT02, ST MEMS audio sensor, omnidirectional digital microphone•CS43L22, audio DAC with integrated class D speaker driver•Eight LEDs:–LD1 (red/green) for USB communication–LD2 (red) for 3.3V power on–Four user LEDs, LD3 (orange), LD4 (green), LD5 (red) and LD6 (blue)– 2 USB OTG LEDs LD7 (green) VBus and LD8 (red) over-current•Two pushbuttons (user and reset)•USB OTG with micro-AB connector•Extension header for LQFP100 I/Os for quick connection to prototyping board and easy probingHardware and layout UM1472 4 Hardware and layoutThe STM32F4DISCOVERY is designed around the STM32F407VGT6 microcontroller in a100-pin LQFP package.Figure2 illustrates the connections between the STM32F407VGT6 and its peripherals (ST-LINK/V2, pushbutton, LED, Audio DAC, USB, ST MEMS accelerometer, ST MEMSmicrophone, and connectors).Figure3 and Figure4 help you to locate these features on the STM32F4DISCOVERY.UM1472Hardware and layoutNote:Pin 1 of CN2, CN3, JP1, P1 and P2 connectors are identified by a square.Hardware and layout UM14724.1 STM32F407VGT6 microcontrollerThis ARM Cortex-M4 32-bit MCU with FPU has 210 DMIPS, up to 1 MB Flash/192+4KB RAM, USB OTG HS/FS, Ethernet, 17 TIMs, 3 ADCs, 15 comm. interfaces and a camera.Figure 5. STM32F407VGT6 packageThis device provides the following benefits.•168 MHz/210 DMIPS Cortex-M4 with single cycle DSP MAC and floating point unitproviding:Boosted execution of control algorithms More features possible for your applications Ease of useBetter code efficiency Faster time to marketElimination of scaling and saturation Easier support for meta-language tools •Designed for high performance and ultra fast data transfers; ART Accelerator, 32-bit, 7-layer AHB bus matrix with 7 masters and 8 slaves including 2 blocks of SRAM, MultiDMA controllers: 2 general purpose, 1 for USB HS, 1 for Ethernet, One SRAM block dedicated to the core, providing performance equivalent to 0-wait execution from Flash Concurrent execution and data transfers and simplified resource allocation •Outstanding power efficiency; Ultra-low dynamic power, RTC <1 μA typical in VBATmode, 3.6 V down to 1.7 V VDD, Voltage regulator with power scaling capability,providing extra flexibility to reduce power consumption for applications requiring both high processing and low power performance when running at low voltage or on a rechargeable battery •Maximum integration: Up to 1 Mbyte of on-chip Flash memory, 192 Kbytes of SRAM,reset circuit, internal RCs, PLLs, WLCSP package available, providing more features in space constrained applications •Superior and innovative peripherals providing new possibilities to connect andcommunicate high speed data and more precision due to high resolution •Extensive tools and software solutions providing a wide choice within the STM32ecosystem to develop your applications.-3 634- & 6'4-BYTE OF &LASH MEMORY +BYTES OF 2!-,1&0 X MM4.2 Embedded ST-LINK/V2The ST-LINK/V2 programming and debugging tool is integrated on theSTM32F4DISCOVERY. The embedded ST-LINK/V2 can be used in 2 different ways according to the jumper states (see Table 2): •Program/debug the MCU on board, •Program/debug an MCU in an external application board using a cable connected toSWD connector CN2. The embedded ST-LINK/V2 supports only SWD for STM32 devices. For information about debugging and programming features refer to user manual UM1075 (ST-LINK/V2 in-circuit debugger/programmer for STM8 and STM32) which describes in detail all the ST-LINK/V2 features.Figure 7. Typical configuration-3 6(ARDWARE REQUIREMENTS 53" CABLE TYPE ! TO MINI "COMPUTER WITH 7INDOWS 80 6ISTA OR $EVELOPMENT TOOLCHAIN!LTIUM 4!3+).' 68 4OOLSET !TOLLIC 4RUE345$)/)!2 %7!2-+EIL -$+ !2-4.2.1 Using ST-LINK/V2 to program/debug the STM32F4 on boardTo program the STM32F4 on board, simply plug in the two jumpers on CN3, as shown inFigure8 in red, but do not use the CN2 connector as that could disturb communication withthe STM32F407VGT6 of the STM32F4DISCOVERY.06Y 94.2.2 Using ST-LINK/V2 to program/debug an external STM32 applicationIt is very easy to use the ST-LINK/V2 to program the STM32 on an external application.Simply remove the 2 jumpers from CN3 as shown in Figure9, and connect your applicationto the CN2 debug connector according to Table3.Note:SB11 must be OFF if you use CN2 pin 5 in your external application.06Y 9DocID022256 Rev 44.3 Power supply and power selectionThe power supply is provided either by the host PC through the USB cable, or by anexternal 5V power supply.The D1 and D2 diodes protect the 5V and 3V pins from external power supplies:•5V and 3V can be used as output power supplies when another application board is connected to pins P1 and P2.In this case, the 5V and 3V pins deliver a 5V or 3V power supply and powermA.consumption must be lower than 100•5V can also be used as input power supplies e.g. when the USB connector is not connected to the PC.In this case, the STM32F4DISCOVERY board must be powered by a power supply unitor by auxiliary equipment complying with standard EN-60950-1: 2006+A11/2009, andmust be Safety Extra Low Voltage (SELV) with limited power capability.4.4 LEDs•LD1 COM: LD1 default status is red. LD1 turns to green to indicate thatcommunications are in progress between the PC and the ST-LINK/V2.•LD2 PWR: red LED indicates that the board is powered.•User LD3: orange LED is a user LED connected to the I/O PD13 of theSTM32F407VGT6.•User LD4: green LED is a user LED connected to the I/O PD12 of theSTM32F407VGT6.•User LD5: red LED is a user LED connected to the I/O PD14 of the STM32F407VGT6.•User LD6: blue LED is a user LED connected to the I/O PD15 of the STM32F407VGT6.•USB LD7: green LED indicates when VBUS is present on CN5 and is connected to PA9 of the STM32F407VGT6.•USB LD8: red LED indicates an overcurrent from VBUS of CN5 and is connected to the I/O PD5 of the STM32F407VGT6.4.5 Pushbuttons•B1 USER: User and Wake-Up button connected to the I/O PA0 of theSTM32F407VGT6.•B2 RESET: Pushbutton connected to NRST is used to RESET the STM32F407VGT6.4.6 On board audio capabilityThe STM32F4 uses an audio DAC (CS43L22) to output sounds through the audio mini jackconnector.The STM32F4 controls the audio DAC through the I2C interface and processes digitalsignals through I2S connection or analog input signal.•The sound can come independently from different inputs:–ST MEMS microphone (MP45DT02): digital using PDM protocol or analog when using the low pass filter.–USB connector: from external mass storage such as a USB key, USB HDD, and so on.–Internal memory of the STM32F4.•The sound can be output in different ways through audio DAC:–Using I2S protocol–Using the STM32F4 DAC to analog input AIN1x of the CS43L22–Using the microphone output directly via a low pass filter to analog input AIN4x of the CS43L224.7 USB OTG supportedThe STM32F4 is used to drive only USB OTG full speed on this board. The USB micro-ABconnector (CN5) allows the user to connect a host or device component, such as a USBkey, mouse, and so on.Two LEDs are dedicated to this module:•LD7 (green LED) indicates when VBUS is active•LD8 (red LED) indicates an overcurrent from connected device4.8 Motion sensor (ST MEMS LIS302DL or LIS3DSH)Two different versions of motion sensor (U5 in schematic) are available on the boarddepending the PCB version. The LIS302DL is present on board MB997B (PCB revision B)and the LIS3DSH is present on board MB997C (PCB rev C).The LIS302DL or LIS3DSH are both an ultra compact low-power three-axis linearaccelerometer.It includes a sensing element and an IC interface able to provide the measured accelerationto the external world through I2C/SPI serial interface.The LIS302DL has dynamically user selectable full scales of +-2g/+-8g and it is capable ofmeasuring acceleration with an output rate of 100Hz to 400Hz.The LIS3DSH has ±2g/±4g/±6g/±8g/±16g dynamically selectable full-scale and it is capableof measuring acceleration with an output data rate of 3.125Hz to 1.6kHz.The STM32F4 controls this motion sensor through the SPI interface.4.9 JP1(Idd)Jumper JP1, labeled Idd, allows the consumption of STM32F407VGT6 to be measured byremoving the jumper and connecting an ammeter.•Jumper on: STM32F407VGT6 is powered (default).•Jumper off: an ammeter must be connected to measure the STM32F407VGT6 current, (if there is no ammeter, the STM32F407VGT6 is not powered).4.10 OSCclock4.10.1 OSC clock supplyIf PH0 and PH1 are only used as GPIOs instead of as a clock, then SB13 and SB14 areclosed and R24, R25 and R68 are removed.•MCO from ST-LINK. From MCO of the STM32F103. This frequency cannot be changed, it is fixed at 8MHz and connected to PH0-OSC_IN of the STM32F407VGT6.Configuration needed:–SB13, SB14 OPEN–R25(a) removed–R68(a) soldered•Oscillator onboard. From X2 crystal. For typical frequencies and its capacitors and resistors, please refer to the STM32F407VGT6 Datasheet. Configuration needed:–SB13, SB14 OPEN–R25(a) soldered–R68(a) removed•Oscillator from external PH0. From external oscillator through pin 7 of the P2 connector. Configuration needed:–SB13 closed–SB14 closed–R25 and R68 removed32KHz clock supply4.10.2 OSCIf PC14 and PC15 are only used as GPIOs instead of as a clock, then SB15 and SB16 areclosed, and R21 and R22 are removed.•Oscillator onboard. From X1 Crystal (not provided). Configuration needed:–SB15, SB16 OPEN–C16, C27, R21 and R22 soldered.•Oscillator from external PC14. From external oscillator trough the pin 9 of P2 connector. Configuration needed:–SB16 closed–SB15 closed–R21 and R22 removeda.As the frequency supplied by X2 is the same as MCO (8MHz) R25 and R68 are soldered.bridges4.11 Solder1.Default SBx state is shown in bold.2.SB13 and SB14 are OFF to allow the user to choose between MCO and X2 crystal for clock source.4.12 ExtensionconnectorsThe male headers P1 and P2 can connect the STM32F4DISCOVERY to a standardprototyping/wrapping board. STM32F407VGT6 GPI/Os are available on these connectors.P1 and P2 can also be probed by an oscilloscope, logical analyzer or voltmeter.UM1472Hardware and layoutHardware and layout UM1472UM1472Hardware and layoutMechanical drawing UM1472DocID022256 Rev 45 Mechanical drawingUM1472Electrical schematicsschematics6 ElectricalElectrical schematics UM1472UM1472Electrical schematicsElectrical schematics UM1472UM1472Electrical schematicsElectrical schematics UM1472UM1472Revision historyhistory7 RevisionUM1472Please Read Carefully:Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice.All ST products are sold pursuant to ST’s terms and conditions of sale.Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein.No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN: (A) SAFETY CRITICAL APPLICATIONS SUCH AS LIFE SUPPORTING, ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS; (B) AERONAUTIC APPLICATIONS; (C) AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS, AND/OR (D) AEROSPACE APPLICATIONS OR ENVIRONMENTS. WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE, THE PURCHASER SHALL USE PRODUCTS AT PURCHASER’S SOLE RISK, EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE, UNLESS A PRODUCT IS EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR “AUTOMOTIVE, AUTOMOTIVE SAFETY OR MEDICAL” INDUSTRY DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS. PRODUCTS FORMALLY ESCC, QML OR JAN QUALIFIED ARE DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY.Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST.ST and the ST logo are trademarks or registered trademarks of ST in various countries.Information in this document supersedes and replaces all information previously supplied.The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.© 2014 STMicroelectronics - All rights reservedSTMicroelectronics group of companiesAustralia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America。

相关文档
最新文档