UM2092 User manual. Basic metrology firmware for the STM32F103RD and the STPM32 devices. Introduction

Similar documents
AN5123 Application note

AN4872 Application note

EVLKSTCOMET10-1. STCOMET smart meter system-on-chip development kit. Features

UM1719 User manual. The STPM3x evaluation software. Introduction

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

UM2255 User manual. SPC58NG-DISP user manual. Introduction

RN0084 Release note. ST-LINK/V2 firmware upgrade. About this release note

Getting started with the digital MEMS microphone expansion board based on MP34DT01-M for STM32 Nucleo

Description. July 2016 DocID Rev 2 1/6

UM2343 Application note

L9958 Evaluation board for high current (8.6A) DC and Stepper Motors. Description

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery Data brief. Features. Description

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery. Features. Description

UM2051 User manual. Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery. Introduction

Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery with the Nucleo-F072RB board and the STUSB1602

UM1844 User manual. EVAL-L9958 Graphical user interface (GUI) Introduction

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

STM32SnippetsL0. STM32L0xx Snippets firmware package. Features. Description

AN4515 Application note

AN4045 Application note

UM2091 User manual. EVAL-L9301 Demo board Hardware documentation. Introduction

STSW-L9960, STSW-L9960T Graphical User Interface (GUI) for EVAL-L9960 & EVAL-L9960T

UM1750 User manual. STEVAL-IPE023V1: STPMxx programmer. Introduction

Using the GPIOs and interrupt controller to drive LEDs on STM8 Nucleo-64 boards

UM2330 User manual. ST8500 boot. Introduction

Description. January 2019 DB2381 Rev 3 1/5

UM2167 User manual. OrCAD PSpice model usage instructions

Motor control power board based on the SLLIMM-nano 2 nd series

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

This manual provides information for the final user application developer on how to use SPC57S-Discovery microcontroller evaluation board.

STSW-STWBCFWDT. STWBC firmware downloader tool. Description. Features

UM2119 User manual. Graphical user interface (GUI) for EVAL-L9907-H. Introduction

NUCLEO-L496ZG. STM32 Nucleo-144 board. Features. Description

How to configure the BlueNRG-1 and BlueNRG-2 devices in network coprocessor mode. Main components Bluetooth Low Energy wireless system-on-chip

AN4373 Application note

Getting started with STEVAL-IDB007V1 and STEVAL-IDB008V1 evaluation boards

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on STUSB1602. Description

X-NUCLEO-53L0A1. Ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo. Description. Features

AN3980 Application note

EVALSTGAP1AS. Demonstration board for STGAP1AS galvanically isolated single gate driver. Description. Features

AN4782 Application note

Getting started with the high power stepper motor driver expansion board based on powerstep01 for STM32 Nucleo

AN4311 Application note

AN3281 Application note

TN1235 Technical note

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

Power line communication expansion board based on ST7580 for STM32 Nucleo. Description

AN4820 Application note

Getting started with X-NUCLEO-IHM06A1 low voltage stepper motor driver expansion board based on STSPIN220 for STM32 Nucleo

AN3996 Application Note

ST25DV-DISCOVERY. Discovery kit for the ST25DV04K dynamic NFC/RFID tag. Features

UM2350. Getting started with MotionPW real-time pedometer for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

NUCLEO-L433RC-P NUCLEO-L452RE-P

How to upgrade the firmware on the STEVAL-USBC2DP USB Type-C to DisplayPort adapter

AN2667 Application note

Getting started with X-NUCLEO-53L1A1 long distance ranging ToF sensor expansion board based on VL53L1X for STM32 Nucleo

DT0095 Design tip. Datalogging the SensorTile through a PC. Purpose and benefits. Description

AN4113 Application note

Getting started with MotionPM real-time pedometer library in X-CUBE-MEMS1 expansion for STM32Cube

Getting started with osxmotiongc gyroscope calibration library for X-CUBE-MEMS1 expansion for STM32Cube

AN4491 Application note

AN4696 Application note

UM1853 User manual. STM32CubeF1 Nucleo demonstration firmware. Introduction

X-NUCLEO-53L1A1. Long distance ranging Time-of-Flight sensor expansion board based on VL53L1X for STM32 Nucleo. Description.

STEVAL-IPMnM2N. Motor control power board based on the SLLIMM-nano 2 nd series. Description. Features. RoHS compliant

Dynamic Electro-Thermal simulator for VIPower products. Description

STSW-BNRG-Mesh. Mesh over Bluetooth low energy. Features. Description. Applications

AN2672 Application note

EV-VND7040AJ. VND7040AJ evaluation board. Features. Applications

Software GUI user guide for STEVAL-ISV021V1, STEVAL- IDS002V1 and STEVAL-IDS003V1 evaluation boards

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on the STUSB1602

AN4749 Application note

Getting started with MotionPM real-time pedometer library in X CUBE-MEMS1 expansion for STM32Cube

AN3279 Application Note

Getting started with X-CUBE-LED channel LED driver software expansion based on LED1642GW for STM32Cube

X-NUCLEO-53L0A1 ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo

AN3975 Application note

Getting started with MotionMC magnetometer calibration library in X-CUBE-MEMS1 expansion for STM32Cube

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

Bluetooth low energy profiles for the X-CUBE-BLE1 expansion for STM32Cube. Description

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

AN5224. STM32 DMAMUX: the DMA request router. Application note. Introduction

P-NUCLEO-IKA02A1. STM32 Nucleo pack: electrochemical toxic gas sensor expansion board with CO sensor. Description. Features

AN2781 Application note

UM2084 User manual. Getting started with the ultra-low-power STM32 and LoRa Nucleo pack. Introduction

EMIF06-HSD04F3. 6-line low capacitance IPAD for micro-sd card with EMI filtering and ESD protection. Features. Application.

AN2261 APPLICATION NOTE

AN2676 Application note

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

EVAL6470H. Fully integrated stepper motor driver mounting the L6470. Description. Features

AN4274 Application note

P-NUCLEO-53L1A1. VL53L1X nucleo pack with X-NUCLEO-53L1A1 expansion board and STM32F401RE nucleo board. Description. Features

STSW-BNRGUI. BlueNRG GUI SW package. Data brief. Features. Description

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

UM2194. Getting started with MotionAW activity recognition for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

Getting started with the ultra-low-power STM32 and LoRa Nucleo pack

P-NUCLEO-6180X2. Proximity, gesture, ambient light sensor expansion board based on VL6180X for STM32L053R8. Description. Features

UM1982 User manual. Multi-Sensor RF 868 MHz platform. Introduction

AN2792 Application note

UM1699 User manual. SPC563M-DISP Discovery+ evaluation board. Introduction

Transcription:

User manual Basic metrology firmware for the STM32F103RD and the STPM32 devices Introduction The following document describes a firmware for the STM32F103RD microcontroller to manage the STPM32 metrology device. This firmware can be tested using two evaluation boards, the STEVAL- IPE023V1 and the EVALSTPM32. The package includes: The initialization of the STM32F103RD The reset sequence of the STPM32 The communication through UART or SPI The block transfer in read and write mode The data latch through SYN pin A basic metrology application, based on the STM32F103RD timer, to read energy and voltage The STM32F103RD initialization uses the Cube MX tool chain. The STPM32 driver integration is based on IAR tool chain with I-JET pod. For further reference please refer to STPM32 and STM32F103RD datasheets. July 2016 DocID029549 Rev 1 1/13 www.st.com

Contents UM2092 Contents 1 Cube MX configuration... 3 2 STPM32 configuration... 4 2.1 Communication mode... 4 2.2 Reset... 5 2.3 SPI and UART communication modes... 5 2.4 Latch data measure... 5 3 Firmware block diagram... 6 3.1 Integration with IAR tool chain... 6 3.2 St_device.h... 9 3.3 Metro Task.c... 9 3.4 STPM3x configuration... 9 3.5 Data with Live Watch... 9 4 STEVAL-IPE023V1 board update... 11 4.1 SPI configuration... 11 4.2 UART configuration... 11 5 Revision history... 12 2/13 DocID029549 Rev 1

Cube MX configuration 1 Cube MX configuration The STEVAL-IPE023V1 contains the STM32F103RDT microcontroller, configured as follows: RCC high speed clock HSE (crystal/ceramic resonator) and RCC high speed clock LSE (crystal/ceramic resonator) SYS debug JTAG (5 pin) SPI 1 is used in full duplex mode with hardware NSS signal disable Frame format: Motorola Data size: 8 bits First bit: MSB first Clock polarity: high Clock phase: 2 edge CRC calculation: disabled TIM3 clock source internal clock USART3 in asynchronous mode with hardware flow control disable Baud rate: 9600 bits/s Word length: 8 bits Parity: none Stop bits: 1 Data direction: receive and transmit TIM3 is used for basic metering application SPI and USART configuration depends on the topology used DocID029549 Rev 1 3/13

STPM32 configuration UM2092 2 STPM32 configuration 2.1 Communication mode The STPM32 is configured during the startup in SPI or in UART mode. If the SCS is set low and EN pin goes from low to high, the STPM32 communicates by SPI mode. If the SCS is set high and EN pin goes from low to high, the STPM32 communicates by UART mode. The STPM32 EN pin can be tied to VDD thanks to a pull-up if it is not driven (EVALSTPM32 board). In this case, no additional wire between the STM32F103RD and the STPM32 is needed. The STM32F103RD pins are in input floating mode at the startup, so on SCS is needed: Pull-down network to communicate by SPI Pull-up network to communicate by UART In the FW, there is not any code related to this since it is pure HW mechanism. Figure 1: UART communication peripheral selection Figure 2: SPI communication peripheral selection EN pin can be also driven by FW: Put EN low to reset the configuration Set the desired level on SCS (for SPI or UART) Put EN high level to latch the configuration In the FW, this service is included into Metro_Init() and it is called Metro_power_up_device(). The choice of the GPIO is in st_device.h. 4/13 DocID029549 Rev 1

2.2 Reset STPM32 configuration As mentioned in the STPM32 datasheet, after the POR, the chip must be reset by toggling 3 times SYN pin and once SCS pin. Figure 3: Reset signal In the FW, the complete sequence is in the function Metro_Init(). 2.3 SPI and UART communication modes In SPI mode the communication speed is based on the SPI clock. In UART mode, by default, the STPM32 works at 9600 bauds. In order to speed up the communication, please use Metro_UartSpeed(uint32_t baudrate) function to change the baud rate. 2.4 Latch data measure The STPM32 registers can be latched in different ways: By FW, by setting latch bits in DSPCTRL3 register By HW, using SYN pin (this method is used in the FW) The choice of the method depends on the function uint8_t Metro_Set_Latch_device_type (METRO_NB_Device_t in_metro_device, METRO_Latch_Device_Type_t in_metro_latch_device_type). DocID029549 Rev 1 5/13

Firmware block diagram UM2092 3 Firmware block diagram The metrology package includes: STPM32 reset management STPM32 latch configuration STPM32 latch management STPM32 read and write access STPM32 computation for metrology measurement (in basic application energy and RMS measure) Figure 4: Firmware block diagram 3.1 Integration with IAR tool chain The firmware has been developed for the STM32F103RD, but it can be easily ported to other STM32 microcontrollers with minor changes. The microcontroller part number is selected into the IAR configuration and in main.c. The metrology package is put at the same level as the other folders in Cube. Figure 5: Folder organization In the IAR tool chain, folders and files need to be added. The following organization is used: 6/13 DocID029549 Rev 1

Figure 6: IAR file organization Firmware block diagram After the integration of files into the project, they need to be included. The following symbols must be defined for the compiler: SPI_XFER_STPM3X for SPI communication UART_XFER_STPM3X for UART communication It is possible to choose directly the configuration in the project by selecting the right compile flag. Figure 7: SPI/UART release There are two sections in which C/C++ compiler and assembler options can be updated. DocID029549 Rev 1 7/13

Firmware block diagram Figure 8: Compiler update UM2092 Figure 9: Assembler update Into main.c file the configuration functions must be changed to be adapted to the HW configuration. 8/13 DocID029549 Rev 1

3.2 St_device.h This file includes all #define used mainly for the communication, for example: SPI used UART used UART speed after initialization CS and SYN pins Firmware block diagram This file must be updated according to the CUBE MX definitions for the specific STM32 part number. 3.3 Metro Task.c This file includes the functions: METRO_Init(): this function initializes the STPM3x (POR sequence), configures the STPM3x by writing internal registers and selects the latch type METRO_Update_Measures: it reads the data from the STPM3x METRO_latch_Measures: it handles the STPM3x latch 3.4 STPM3x configuration The FW handles up to four different STPM3x devices, but in the present deployment one device only, called EXT1, is defined. Besides, the code can support different STPM3x devices (STPM32, STPM33, STPM34). The STPM3x configuration register settings are defined into metrodefault (handler_metrology.c). The first U32 word is the STPM3x type and number of supported channels 19 x U32 words contain the settings to write into DSPCTRL registers 2 x U32 words contain the power conversion factor for conversion of register value to Watt. The value depends on the AFE components of the application 2 x U32 words contain the voltage conversion factor for conversion of register value to Volt 2 x U32 words contain the current conversion factor for conversion of register value to Ampere 3.5 Data with Live Watch Data can be read in live mode debug using "Live Watch" view. By adding the variables, Tab_METRO_internal_Devices_Config and metrodata to "Live Watch" window, the raw registers can be monitored from the STPM32 and the measurement data calculated by the basic metrology application. DocID029549 Rev 1 9/13

Firmware block diagram Figure 10: Live Watch UM2092 10/13 DocID029549 Rev 1

STEVAL-IPE023V1 board update 4 STEVAL-IPE023V1 board update 4.1 SPI configuration In order to have the STPM32 available for the communication, a 10 k pull-down resistor can be placed on SPI1-NSS line (host side). 4.2 UART configuration The STEVAL-IPE023V1 board does not support by default the UART mode. A simple UART communication can be set up, but in this case the metrology board works without galvanic isolation. To enable UART communication, on the STEVAL-IPE023V1 board: Remove the connection STPMxx_MOSI between the STPM32 connector and U5 Remove the connection STPMxx_SDA_MISO between the STPM32 connector and U3/U4 Connect both of GND (isolated and no-isolated) Connect J3-2 to PB10/USART3-TX Connect J3-4 to PB11/USART3-RX Place 10 k pull-up on SPI1-NSS line To isolate from mains, place an isolator over RX and TX line and no connection between the two GND. DocID029549 Rev 1 11/13

Revision history UM2092 5 Revision history Table 1: Document revision history Date Revision Changes 26-Jul-2016 1 Initial release. 12/13 DocID029549 Rev 1

IMPORTANT NOTICE PLEASE READ CAREFULLY STMicroelectronics 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. 2016 STMicroelectronics All rights reserved DocID029549 Rev 1 13/13