资料介绍
Table of Contents
AD7124 Example on STM32 Processors
Introduction
This describes how to take the AD7124 example code and integrate it with STM32 firmware libraries in a suitable development environment to produce a complete program. The IDE used here is the STM32CubeIDE, but the general procedure can be applied to other IDEs.
Useful links
Overview
The AD7124 is a low power, low noise, completely integrated analog front end for high precision measurement applications. The device contains a low noise, 24-bit Σ-Δ analog-to-digital converter (ADC). The AD7124 example application provides a terminal based console interface that allows a user to select between different configurations, and to sample data in single or continuous conversion modes.
The example makes use of the AD7124 No-OS software drivers and platform drivers that are using the STM32 HAL firmware libraries.
Software Integration Guide
Downloads
Project Creation
- If you have not already done so, install the STM32CubeIDE available from www.st.com.
- In the Firmware Update section of the STM32CubeIDE preferences, set the location to where the firmware package is going to be stored.
- You may want to place this in a common location, e.g. 'C:/ST/Repository' and not in a directory located under your home directory, to avoid user specific paths in any shared configuration files
- Select the File » New » STM32 project menu option.
- Select the MCU part number or Board being used
- Give the Project a name, select target language, and project type of STM32Cube
- Make sure the Target Reference is correct as it can't be changed once the project is created, and the firmware package repository path is as expected. Set the Code Generator Options to reference library files, or copy library files in your project, depending on how you want to structure your project.
- When you click Finish, the STM32CudeIDE will download the firmware library if required and unzip it to the repository location specified above. This file is typically 100's MB in size so this will take several minutes to complete.
Configuring the Project
The Device Configuration Tool with automatic code generation is used to define pin usage and other default modes of operation for the NUCLEO-L476. In addition there are some build and linker settings that may be required depending on the default project build configuration.
Device Configuration Tool
A 4-wire SPI bus is used to connect AD7124 to the NUCLEO-L476RG board, and a UART is used to provide the serial I/O for the console interface. An LED is also used to indicate activity. The following sections detail the configuration settings that need to be made for each of these.
SPI
SPI1 port on the processor is used to communicate with the AD7124, with the pin assigned to each function as shown here, with the corresponding label.
The pin PB10 is used as a software controlled chips select for SP1, and so its mode must be set to GPIO_output, and set the user label to SPI1_NSS to match what is used in the platform driver file. The Connectivity » SPI1 configuration settings are shown here.
DMA and interrupts are not used and don't need to be configured. The SPI1 GPIO Settings are as follows.
Serial UART
The serial port uses USART2, and no DMA or interrupts need to be configured.
The USART2 GPIO settings are as shown.
GPIO
An LED is toggled on the NUCLEO-L476 board to indicate sampling and other activity. The activity LED is controlled by Port A, Pin 5, and needs to enabled as digital output to support this function.
Build Settings
The printf(…) function is used to print numbers formatted as floating point values in the terminal view. As this feature is often disabled by default due to the additional memory requirement, floating point support in printf(…) must be enabled. In the Project properties window, under 'C/C++ Build » Settings » MCU GCC linker » Miscellaneous > Other Flags' add a '-u _printf_float' option.
If there are other source or include directories that need to be added to support the project build, they should also be added to the relevant 'Include paths' in the MCU GCC Compiler section as required.
Linker Files
The default value for _estack may be incorrect in the *.ld files. This can cause problems when calling into certain library functions. In particular this can prevent the %f format specifier working with the floating point version of printf(…). If instead of a value like '1.23', the terminal output is '0.00', this can indicate a need to update the linker *.ld files. For the NUCLEO-L476RG, the RAM and the FLASH versions of the ld files contain the following:
/* Highest address of the user mode stack */ _estack = 0x20017fff; /* end of "RAM" Ram type memory */
Changing this as follows fixes the issues related to floating point support in printf:
/* Highest address of the user mode stack */ _estack = 0x20018000; /* end of "RAM" Ram type memory */
Source File Edits
When using the Device Configuration Tool, the code generator produces a two of these source files, main.c and main.h need minor edits to integrate the AD7124 example code. There may be an edit required to the _read(…) function in syscalls.c to work around an issue, but whether this is required, will depend on the specific library and build environment.
main.c
To keep the integration of the AD7124 example application with other user and platform specific code, there are only two functions that a user needs to call from their own code, typically as part of the main function.
- ad7124_app_initialize(..) that does all the one-time initialization work required by the app, mainly AD7124 device setup
- It is strongly recommended to test the return value from this function to determine if the initialization was successful or not
- A value less than 0 indicate failure.
/* Initialize the AD7124 application before the main loop */ int32_t setupResult; if ((setupResult = ad7124_app_initialize(AD7124_CONFIG_A)) < 0 ) { // Handle error setting up AD7124 here }
- adi_do_console_menu(…) displays the user menu to interact with the application features
- This can be called in a while(1) loop so that it is always displayed.
while(1) { // display the console menu for the AD7124 application adi_do_console_menu(&ad7124_main_menu); }
Both are defined in the “ad7124_console_app.h” header which needs to be added as #include file.
main.h
The AD7124 example assumes that all the STM32 hardware is initialized and appropriate SPI and UART port handles are available, and are used in platform_drivers.c and platform_support.c. The following extern declarations for the SPI and serial port handles are required in main.h to make them available to the platform specific code.
extern SPI_HandleTypeDef hspi1; extern UART_HandleTypeDef huart2;
syscalls.c
In the _read(…) function, the 'len' parameter passed in was found to always be '1024' for the library and build environment used to develop the example code.
int _read(int file, char *ptr, int len)
In order to support the use of getchar(), the expression 'len = 1;' was added immediately before the for loop in the _read(…) function. While this is sufficient for getchar() to work, it does not support use of other stdio.h functions such as scanf(…).
Adding AD7124 Example Files
The distribution of the AD7124 source and header files can be added to the project that has been created. The files can be added in a dedicated 'adi' directory, or in the main 'src' directory, or split as appropriate between 'src' and 'inc' directories, according to the file structure being used. If adding new source and header file locations, then these will need to be added to the build settings as necessary, in the relevant 'Include paths' in the MCU GCC Compiler configuration.
At this point, assuming that any necessary changes, pin names, port usage/configuration have been made, the project should compile cleanly.
Hardware Connections
Power & USB
A 9V DC supply (barrel jack, center pin positive) is required to power the EVAl-AD7124-8SDZ evaluation board. The NUCLEO-476RG is powered via the USB connection to the PC, which also provides the serial UART connection back to the PC. The NUCLEO-476 creates a COM port that can be connected to by a terminal emulator, e.g. putty.
SPI Interface
SPI connections to the host processor board can be made to the relevant test points on the eval board, or more easily with an SDP Breakout Board.
AD7124 SPI Signal | SDP Breakout Board | NUCLEO-L476 |
---|---|---|
GND | 81 | GND on CN5.7 |
SCLK | 82 | D3 (PB3) on CN9.4 |
DOUT/RDYB | 83 | D5 (PB4) on CN9.6 |
DIN | 84 | D4 (PB5) on CN9.5 |
CSB | 85 | D6 (PB10) on CN9.7 |
Analog Input
The screw terminal connections to J6 and J11 can be used to connect appropriate analog input signals to provide test stimulus to the AD7124.
In Configuration A
- AIN0/AIN1 are used for channel 0, simple voltage measurement
In Configuration B
- AIN2/AIN3 go to the A2 thermocouple connector on the evaluation board, and are captured on channel 0. This uses an internal reference and has a bias voltage enabled on AIN2. A suitable thermocouple should connected to A2 for this measurement.
- AIN4/AIN5 are an RTD1000 measurement on channel 1. Excitation is provided from AIN1 for this. This requires an external RTD and reference resistor connected as show in the figure below.
Console Application
Once the hardware connections are made, and the compiled code programmed into the board, open the terminal program, and reset the hardware to see the AD7124 menu that allows a user to perform a variety of functions. These include reset the device, program one of the pre-defined configurations, and sample data that is displayed on screen or streamed so it can captured by the console.
- 基于MDK的STM32处理器开发应用.zip
- 到底64位处理器和32位处理器有什么区别呢?资料下载
- “硬件软件化”,32位处理器的开发与8位处理器的开发资料下载
- 晶晨S905X4处理器快速参考手册下载 24次下载
- STM32处理器存储空间布局解析资料下载
- ADuCM3029处理器上的温度-BLE演示
- STM32系列Cortex-M3处理器编程手册免费下载 37次下载
- 基于MDK的STM32处理器开发应用PDF电子教材免费下载 59次下载
- STM32处理器的锂电池组保护电路设计 29次下载
- 基于STM32处理器的锂电池快速充电设计 25次下载
- 基于STM32处理器的μC_OS_移植 6次下载
- STM32系列ARM Cortex-M3处理器微控制器原理与实践 24次下载
- 在W78E58处理器上移植的uCOS-II 12次下载
- 基于STM32处理器和PC主机的USB通信协议的实现 68次下载
- 基于ARM的PC/104处理器模块设计
- 基于全志V853处理器的智能辅助驾驶算法介绍 96次阅读
- STM32处理器A/D转换输入电阻与采样时间的分析 8472次阅读
- 全志T507处理器如何实现SPI转CAN功能 2286次阅读
- 对Cortex-A53处理器的性能分析及特点概述 13.9w次阅读
- 分析Cortex-A7处理器与Cortex-A15处理器各自的优势及区别 6607次阅读
- 华为麒麟980处理器规格曝光 5209次阅读
- cortex-a9是什么处理器_cortex-a9处理器介绍 2.5w次阅读
- TMS320C6678处理器的VLFFT演示探讨与研究 4220次阅读
- a11处理器比a10快多少_A11处理器性能媲美英特尔i7? 1105次阅读
- 骁龙625处理器与骁龙652处理器对比评测 10.3w次阅读
- 详细剖析高通发布的骁龙845处理器 5279次阅读
- 单一处理器简化RFID读取器设计及RFID系统范例分析 1198次阅读
- 32位嵌入式处理器与8位处理器应用开发的区别 1528次阅读
- 苹果推出64位处理器:对手机而言,意味着什么? 3983次阅读
- 高通披露Snapdragon 400和200处理器细节 1137次阅读
下载排行
本周
- 1电子电路原理第七版PDF电子教材免费下载
- 0.00 MB | 1491次下载 | 免费
- 2单片机典型实例介绍
- 18.19 MB | 95次下载 | 1 积分
- 3S7-200PLC编程实例详细资料
- 1.17 MB | 27次下载 | 1 积分
- 4笔记本电脑主板的元件识别和讲解说明
- 4.28 MB | 18次下载 | 4 积分
- 5开关电源原理及各功能电路详解
- 0.38 MB | 11次下载 | 免费
- 6100W短波放大电路图
- 0.05 MB | 4次下载 | 3 积分
- 7基于单片机和 SG3525的程控开关电源设计
- 0.23 MB | 4次下载 | 免费
- 8基于AT89C2051/4051单片机编程器的实验
- 0.11 MB | 4次下载 | 免费
本月
- 1OrCAD10.5下载OrCAD10.5中文版软件
- 0.00 MB | 234313次下载 | 免费
- 2PADS 9.0 2009最新版 -下载
- 0.00 MB | 66304次下载 | 免费
- 3protel99下载protel99软件下载(中文版)
- 0.00 MB | 51209次下载 | 免费
- 4LabView 8.0 专业版下载 (3CD完整版)
- 0.00 MB | 51043次下载 | 免费
- 5555集成电路应用800例(新编版)
- 0.00 MB | 33562次下载 | 免费
- 6接口电路图大全
- 未知 | 30320次下载 | 免费
- 7Multisim 10下载Multisim 10 中文版
- 0.00 MB | 28588次下载 | 免费
- 8开关电源设计实例指南
- 未知 | 21539次下载 | 免费
总榜
- 1matlab软件下载入口
- 未知 | 935053次下载 | 免费
- 2protel99se软件下载(可英文版转中文版)
- 78.1 MB | 537793次下载 | 免费
- 3MATLAB 7.1 下载 (含软件介绍)
- 未知 | 420026次下载 | 免费
- 4OrCAD10.5下载OrCAD10.5中文版软件
- 0.00 MB | 234313次下载 | 免费
- 5Altium DXP2002下载入口
- 未知 | 233046次下载 | 免费
- 6电路仿真软件multisim 10.0免费下载
- 340992 | 191183次下载 | 免费
- 7十天学会AVR单片机与C语言视频教程 下载
- 158M | 183277次下载 | 免费
- 8proe5.0野火版下载(中文版免费下载)
- 未知 | 138039次下载 | 免费
评论
查看更多