Chinese STM32 Oled soldering controller – part2

By | February 14, 2018

Development environment

Lately I have been using the ST’s STM32CubeMX for pin, peripherals and midlleware configuration and initial project setup, and Ac6’s System Workbench for STM32 for code editing and debugging. They are both free and cross platform.

Starting with the STM32Cube software and working from the schematic from the previous post, we first create a project defining the processor type and continue by defining our inputs and outputs as follows:

Digital inputs

  • 3 inputs for the rotary switch plus button – configuration not critical in terms of speed or input type
  • 1 input for the wake from sleep functionality – “

Analog inputs

  • Thermocouple sensor – requires fast readings so best to use DMA
  • Ambient temperature sensor – not critical but since we already have DMA lets go with that
  • Input voltage sensing – same as above
  • Voltage reference – not used, don’t know what was the designer idea with it, probably for ADC calibration but since the STM32F103 ADC has an internal cal system lets just go with that

Digital outputs

  • Buzzer – not critical in terms of speed or output type
  • Iron heating element – using PWM so we can modulate its power
  • Oled’s CS, RESET and DC pint – configured as fast pins

SPI

  • Oled’s MOSI and CLK

We end up with something like:

Naming the pins allows us to refer to them by their name later while coding.

Next we can take care of the clocks. Not much to say here except the this board has no external oscillator so we must configure and use the internal one.

Next we need to configure the peripherals, ADC, SPI, Timers, etc. I won’t go into to much detail about this step, we don’t need to be certain about all the settings since we can always change them later.

For the ADC conversion I opted for the dual combined simultaneous ADC with DMA.

For PWM generation I had to keep the frequency lower than I would like (about 2KHz) due to the Mosfet and driver circuit used which some initial testing shown to have quite slow switching speed.

With the initial project setup we just need to tell the software to generate code for the SW4STM32 and we can choose to open it from there.

First hardware flash

For flashing and debugging the STM32’s I normally use the cheapo st-link clones from aliexpress, they are cheap, but I had two fail on me already (see below).

The board I received had the read protection enabled so I wasn’t able to flash it from within eclipse, I first had to remove the protection using openocd:

openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c “init” -c “halt” -c “stm32f1x unlock 0” -c “shutdown”

On windows the same can be done using the st-link utility

After that, only one small edit needs to be done to the eclipse project:

Go to project->properties->edit->debugger->show generator settings->reset mode, change to software system reset.

Pressing the “run” button should now flash the firmware with no issues.

The problem with the cloned st-links

The problem seems that they come with an STM32F101 working outside it’s specs (according to ST’s the USB on the 101 is not supported), so they eventually fail.

From the three I bought, two failed, to fix them I had to remove the 101 microprocessor, solder a new STM32F103 and flash new st-link firmware (after having a hard time finding it).

What’s next?

On the next post I will present the finished firmware and a few minor hardware changes I made to suit my needs

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.