Getting Started with the WeAct STM32G474CEU6 Long

Contents

WeAct Studio STM32G4x Development Boards

WeAct Studio produce two development boards based on STM32G4x microcontrollers:

  1. STM32G431CBU6 Mini: Clock speed 170 MHz, flash memory 128KB, SRAM 32KB.
  2. STM32G474CEU6 Long: Clock speed 170 MHz, flash memory 512KB, SRAM 128KB.
WeAct STM32G474CEU6 Long microcontroller board
Fig 1 - WeAct STM32G474CEU6 Long microcontroller board

The Mini Core board has insufficient flash memory to run MicroPython firmware and will not be considered further in this series. The STM32G474CEU6 Long board, an excellent candidate for MicroPython, is the theme for these series of articles.

Powering the Powering the WeAct STM32G474CEU6 Long

There are two recommended ways that the board can be powered:

  1.  USB connector: This is the most common method i.e. via a computer's USB port.
  2.  5V pin: Voltage applied to the 5V pin is regulated to 3.3V by the board's LDO (ME6231A33M3G voltage regulator). From the datasheet, this LDO can accept an input voltage between 3.5V to ~18V.

Note: The 3.3 V pins are output only i.e. they are for supplying power to low power peripherals from the Powering the WeAct STM32G474CEU6 Long. Under no circumstance should these pins be used to power the WeAct STM32G474CEU6 Long board.

Installing MicroPython

This series of articles on the WeAct Studio STM32G474CEU6 Long promote the use of MicroPython as the language of choice to using this board as an educational resource.

The board doesn't come preloaded with the MicroPython firmware. You must flash this to the board. Don't despair as this is a relatively simple task!

Our advice is to read through the rest of this introductory article then follow the instructions here, Installing MicroPython, to flash MicroPython on your board.

After MicroPython is installed an IDE (Integrated Development Environment) is required to write and send MicroPython programs to the WeAct STM32G474CEU6 Long board. We use and recommend the industry standard Thonny  IDE. This article discusses Thonny and how to use it with the STM32G474CEU6 Long; The Thonny IDE

The STM32G474CEU6 Microcontroller

As the name suggests the WeAct STM32F411CEU6 Long uses the STM32F411CEU6 Microcontroller! The name can be broken down:

  • STM32: Family of 32-bit microcontrollers from STMicroelectronics.
  • G: Identifies the specific series within the family, G = Mixed signal.
  • 4: Arm Cortex-M4 core with FPU and DSP instructions.
  • 74: High-performance variant with advanced analog and timer features.
  • C: Indicates the pin count i.e. a 48-pin device.
  • E: Specifies the amount of Flash memory i.e. 512 KB of flash memory.
  • U: Indicates the package type i.e. UFQFPN 48-pin package.
  • 6: Denotes the operating temperature range i.e. -40°C to +85°C.

The onboard 512 KB flash is the minimum required to support the MicroPython compiler and runtime system. In practice we found this board runs fine with the MicroPython firmware.

The board is long and narrow; excellent for prototyping on a breadboard. It has a row of 24 pins along each long edge.

Not all of the pins, communication buses, timers, etc that are available on the STM32G474CEU6 MCU are exposed on the WeAct Long board. Some are designed for other uses that the user should't have access to and the board size is also a limitation.

GPIO Pins

There are ample GPIO pins exposed on the STM32F411CEU6 Long for most projects.

Digital pins

All up, the board has 36 digital pins. Of these, there are 30 pins that are 'anytime' available;

  • A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A15
  • B0 .. B7, B9 .. B15
  • C4, C10, C11

Details on the board's digital pins and how to use them can be found in this MicroPython pyb.Pin class article.

Analog pins

There are two different types of analog pins on the WeAct STM32G474CEU6 Long Board:

  • Analog-to-Digital Converter (ADC): A0, A1, A2, A3, B11, B12, B14
  • Digital-to-Analog Converter (DAC): A4, A5

Details on the board's analog pins and how to use them can be found in the following articles: MicroPython pyb.ADC class and MicroPython pyb.DAC class.

Serial Communications

The STM32G474CEU6 Long board has a selection of UART, I2C and SPI serial ports.

UART

The STM32G474CEU6 Long board has three hardware UART available to the user:

  • UART(1): TX: A9, RX: A10
  • UART(3): TX: C10, RX: C11
  • UART(6): TX: A2, RX: A3

Details on the board's UART and how to use it can be found in this MicroPython pyb.UART class article.

I2C

The STM32G474CEU6 Long board has only one hardware I2C interface available:

  • I2C(2): SCL: C4, SDA: A8

The MicroPython pyb module, specific to STM32 microcontrollers with MicroPython firmware, provides an I2C class but this is now considered legacy.

Instead the MicroPython machine module contains an I2C class that provides much more control over the I2C interface. When dealing with some slave devices this extra level of control is required.

Details on the board's I2C hardware interface and how to use it (and supplement with soft I2C interfaces) can be found in this MicroPython machine.I2C class article.

SPI

The STM32G474CEU6 Long board has two separate hardware SPI interfaces available to the user:

  • SPI(1): SCK: B3, MISO: B4, MOSI: B5
  • SPI(2): SCK: B13, MISO: B14, MOSI: B15

Details on the board's SPI interfaces and how to use them can be found in this MicroPython pyb.SPI class article.

Timers

The STM32G474CEU6 Long board has 11 timers for general purpose use. They are referred to as TIM(1)..TIM(8) and TIM(15)..TIM(17).

The timers generally count down at a configured frequency from a given value to 0. The execution of a MicroPython function is triggered at the end of the count down.

The counters are also used to provision PWM (pulse width modulation) on digital pins.

Details on the board's timers and how to use them can be found in this MicroPython pyb.Timer class article.

Real-Time Clock

The STM32G474CEU6 has a full-featured calendar (seconds, minutes, hours, day, date, month, and year), a programmable alarm, and a periodic wake-up unit. It also has backup battery capability that retains the correct time/date when the microcontroller is powered down.

Details on the board's RTC and how to use it can be found in this MicroPython pyb.RTC class article.

External Interrupts

Hardware interrupts are specialized electrical signals that allow external or internal hardware events to immediately pause a microcontroller's main program and execute a dedicated task. A common signal that triggers a hardware interrupt occurs when a given digital pin changes value.

The WeAct STM32G474CEU6 Long has 16 external hardware interrupts (labelled 0 through to 15) that can be used to respond to falling edge, rising edge or either on the board's digital pins.

When the condition occurs on the digital pin the main program is halted and an interrupt service routine ("callback function") is invoked. This allows actions to be taken as a result of an external happening.

Details on the board's external interrupts and how to use them can be found in this MicroPython pyb.ExtInt Class article.

Additional Hardware

Separate to the microcontroller the STM32G474CEU6 Long board has some additional hardware that might be useful in MicroPython programs. This hardware includes:

  • LED: There is a blue user-controllable LED.
  • Switch: A pushbutton switch labelled PC13 on the board's silk; a MicroPython program can detect whether this switch has been pushed.

The following articles discuss in detail how to use these items: MicroPython pyb.LED class and MicroPython pyb.Switch class.

The STM32G474CEU6 Long board doesn't come with a microSD card slot. However it's easy to add this as an expansion board to provide removable file storage. How to add and use a microSD card is discussed in this article: Installing a microSD Expansion Board.