Purpose of creating this program::

  • make microcontroller programming simple
  • remove restrictions on the use of MK resources inherent in Arduino
  • easy integration of your own program code

 What is needed to work with the program:

  • Hardware
  • Software

Hardware

  • Of course, first of all the controller itself. "Blue Pill":
  • USB-UART adapter
  • Micro-USB cable
  • a set of wires for connecting components to each other
  • For faster, in comparison with UART, downloading the "firmware" and debugging programs, it is recommended to use the ST-Link V2 dongle

All used parts / components can be purchased on aliexpress.com.

Software

What is a module?

A module is a combination of hardware and software. The hardware is the STM32F103C8T6 “Blue Pill”, the software is the “firmware template” created using the MIOC program. This program is OpenSource.

Microcontroller ports

The microcontroller has pins or legs. Some of them are power of microcontroller, some have a special purpose (for example, Reset), some are general-purpose input / output interface (GPIO).

Ports are grouped as (A; B; C ...). Each group contains up to 16 ports, numbered from 0 to 15. As a result, the port numbering looks like PA0, PA1, …

Ports are used for communication between the components of the module, for example, a microprocessor and various peripheral devices. Ports can act as input, output, and bidirectional.

The “Blue Pill” board have a marked with ports.

GPIO - General Purpose I / O Interface

The main types of ports the IO module are presented in the table:

GPIOModeAIN

analog input

GPIOModeIN_FLOATING

entrance without pulling ( Float )

GPIOModeIPD

pull-down entrance ( Pull-down )

GPIOModeIPU

pull-up entrance ( Pull-up )

GPIOModeOut_OD

open drain ouput ( Open Drain )

GPIOModeOut_PP

two-state output ( Push-Pull )

GPIOModeAF_OD

open drain output for Alternate Function. Used when pins are controlled by peripherals that can be used on this pin. For example, USART, I2C, and the like.

GPIOModeAF_PP

same as GPIO_ModeAF_OD, but with two states

As sensors, actuators we will use various devices from Arduino.

MIOC (Module Input-Output Configurator) Program

Using this program, we create / configure the firmware template (project for Embitz; Keil) of the IO module. The program does not require of installation. Download, run. Using this program, we create global variables that we will use in our firmware. Variables can be associated with ports.

First run window:

Create a project:

The first program is "hello world" for the microcontroller

Blink the LED, which is on the "blue pill". This LED is connected to the PC13 port.

Add row to variable table

Generate BSP code (F8 button)

Further, each time, after a project change, the generation of BSP is mandatory!

Open the created project in the development environment of EmBitz or Keil. EmBitz is still a temporary solution, it seems the author abandoned this project. Apparently in the future, the project will use Code::Blocks.

In the main.c file, write the following:

(To increase the size of the image, open it in a new tab)

In EmBitz, press F2, after the information window appears, press F7, compilation will be performed. Pressing F2 again will hide the information bookmarks.

Download to the microcontroller, look how it works.

Button

Add a button, for example this:

wiring...

Read more »