- Status
- Warning
- Backup First!
- Setup instructions
- Creating a .ioc file from scratch
- History
- Where are Docs?
- Compatibility
- Developed on STM32CubeIDE - download and use that. This IDE includes the MX code generator
- Tested on STM32F072 (on a QUICKO T12 board).
- Included config for STM32F103 but needs testing
- Should be easily ported to other stm32f0xx/stm32f1xx MCUs.
- Already compiled bins in the Builds folder! (Test at your own risk)
- Intended to serve as an unified codebase that's easier to share across different boards / hardware
Newer hardware is often inferior! With bad low quality component(s) such as:
- Bad Op-Amp
- Bad 3v3 Regulator
Which can then result in bad performance / bad temperature regulation.
- It is recommended to check these above suspect components. And if necessary order better alternatives parts and replace them (before proceeding further).
- This is especially true for many of the newer v2.1 boards and v3.x boards by KSGER.
Usually the MCU will be read-protected, so you won't be able to read its contents, only erase it.
The simplest way to not loose the originl FW is actually to buy a new MCU, then remove the original MCU with hot air, or chipquik, or bizmuth low temperature solder, and store it in a safe place in case you want to revert back.
Keep in mind that there are many versions of the hardware PCB, KSGER and friends keeps changing them all the time, so it might not work even in the MCU is the same.
Any difference in the pinout will require firmware tuning! Although that is one of the proposits of this fork, to ease that part.
DEFINE YOUR HARDWARE FIRST!!
Create a new, empty project in STM32CUBE IDE, selecting your MCU. Name it "T12" for easiness.
If your MCU is not in the included templates list (see below), follow Creating a .ioc file from scratch and then continue Configuring setup.h
When CUBEMX configurator opens, just close it.
Delete the T12.ioc file, checkout or download the code in a zip.
Go to the project folder, and paste Core and Drivers folders, overwriting all files. There are two .ioc (CUBEMX templates) included by default:
- T12-STM32F072.ioc : For Quicko T12 with STM32F072
- T12-STM32F103.ioc : For the STM32F103, as the original FW.
If you are OK with any of these, copy any to the root of the project and rename it to "T12.ioc" Open it, make any small change, ex. take an unused pin and set is as GPIO_Input, then revert it to reset state. This will trigger the code generation. Close saving changes and the code will be generated.
Add the new folders to the include search path! Right click on project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC Compiler -> Include paths
On the upper menu, Configuration, Select [All configurations]
Click on Add... Select Workspace and select these folder while holding Control key:
/Core/Inc
/Core/Src
/Drivers/generalIO
/Drivers/graphics
/Drivers/graphics/gui
Open setup.h and define your board. There are 3 included, uncomment the correct one:
//#define T12_STM072
//#define T12_STM103
//#define YOUR_CUSTOM_CONFIG
If your board use the same MCU but different pinout, you will need to adjust the .ioc and the setup.h config! As long as you use the same PIN labels, you will only need to touch setup.h.
Click in the right arrow of the build button (Hammer icon), select Release, then click on the build button and should build right away.
Videos of the complete build steps here:
STM32F072
STM32F103
Keep in mind that the flash is almost full, so it will not build in debug mode unless you change Build optimizations to -Os(Optimize for size)
If you make a new .ioc file, ex. for a different MCU, follow this guide:
* MISC
- Wake signal from handle: GPIO EXTI*, User label: WAKE, No pull
GPIO config: Rising/falling edge interrupt mode.
Ensure that NVIC interrupt is enabled for it!
- Buzzer signal: GPIO Output, User label: BUZZER, No pull
* ENCODER
- Rotatory encoder right signal: GPIO EXTI*, name: ROT_ENC_R
- Rotatory encoder left signal: GPIO EXTI*, name: ROT_ENC_L
- Rotatory encoder button signal: GPIO EXTI*,name: ROT_ENC_BUTTON
- GPIO config: All EXTI inputs set in rising/falling edge interrupt mode, all no pull
- Ensure that NVIC interrupts are enabled for them!
* OLED
- Oled CS signal: GPIO Output, name: OLED_CS
- Oled DC signal: GPIO Output, name: OLED_DC
- Oled RESET signal: GPIO Output, name: OLED_RST
* SPI
- GPIO Settings:
* Oled SPI CLOCK signal: SPI*_SCK
User Label: SCK
No pull
Speed: High
* Oled SPI DATA signal: SPI*_MOSI
User Label: SDO
No pull
Speed: High
- Parameter settings:
* Mode: Half-Duplex master
* NSS: Disabled
* Data size: 8
* MSB First
* Prescaler: Adjust for max speed, usually the limit is 18Mbit.
* Clock Polarity: Low
* Clock Phase: 1 Edge
* CRC Calculation: Disabled
* NSSP Mode: Disabled
* NSSP SIgnal Type: Software
- DMA Settings:
* SPIx_Tx
* Direction: Memory to pheripheral
* Piority: Low
* DMA request mode: Normal
* Data width: Byte in both
- NVIC Settings:
* DMAx channel interrupt enabled.
* SPIx global interrupt disabled
* ADC
- GPIO config:
* NTC pin label: NTC
* V Supply pin label: V_INPUT
* VRef pin label: VREF
* Iron Temp pin label: IRON_TEMP
- Parameter settings:
* Select channels assigned to the used inputs
* Clock prescaler: Asynchronous clock mode
* Resolution: 12 bit resolution
* Data Alignment: Right alignment
* Scan Conversion Mode: Forward
* Continuous Conversion: Enabled
* DMA Continuous Requests: Enabled
* End Of Conversion Selection: End of Single Conversion
* Overrun behavior: Overrun data preserved
* Low Power Auto Wait: Disabled
* Low Power Auto Power Off: Disabled
* Sampling time: 13.5 cycles
* External Trigger Conversion Source: Regular Conversion Launched by software
* External trigger Conversion Edge: None
* Watchdog disabled
* IF ADJUSTABLE regular channels:
Set channels 1 to 4 to the inputs, all 13.5 cycles.
* IMPORTANT: Configure in setup.h the order of the channels and set their labels accordingly!
The ADC channel order goes from 0 to 15 (unless otherwise set in regular config), skipping the disabled channels.
* #define ADC_CH1 VREF // ADC 1st used channel, ex. ch0
#define ADC_CH2 NTC // ADC 2nd used channel, ex. ch2
#define ADC_CH3 V_INPUT // ADC 3rd used channel, ex. ch3
#define ADC_CH4 IRON_TEMP // ADC 4th used channel, ex. ch7
- DMA settings:
* Pheripheral to memory
* Mode: Circular
* Data width: Half word on both.
- NVIC Settings:
* DMAx channel interrupt enabled.
* ADC and COMP*** interrupts disabled
* BASE TIMER
- Base timer: Usually Timer 3, you might take any.
* Internal clock
* Internal clock division: No division
* Auto-reload preload: Disable
* Master/Slave mode: Disable
* Trigger event selection: Reset (UG bit from TIMx_EGR)
* Set Prescaler and Counter period for 1mS period.
Ex @ 48MHz Ftimer: Prescaler: 8000, Period 6.
8000*6 = 48,000. 48Mhz/48K=1000Hz, 1mS period
* NVIC settings: Enable TIMx Global interrupt.
Consider that some timers will run at CPU speed, while other may take a slower clock.
Check the Clock config in CUBEMX!
* PWM
- GPIO:
* User label: PWM_OUTPUT
* Mode: TIMxCHx(N) ("x" and "N" depends on the selected pin)
- TIMER: Select timer assigned to the pin.
- Check Activated
- Select channel assigned to the pin
- Mode: PWM Generation. Select CHx(N), as assigned to PIN. Ensure to select "N" if the pin has it!
- Counter period: 2000
- Prescaler: Adjust is accordingly to the wanted PWM frequency: Fpwm = FTimer/(2000*prescaler)
Ex: 48MHZ/(2000x480) = 50Hz (There's no need of high PWM frequency in this application)
Consider that some timers will run at CPU speed while other may take a slower clock.
Check the Clock config in CUBEMX!
-
Original version by PTDreamer
-
Updated branch - for v2.1s, from newer fork:
LuckyTomas
, flawless_testing` branch -
Merged to master, with Docs, and minor update by Dreamcat4
-
Compatibility for STM32F072 added by DavidAlfa
-
Adapted and refined with many improvements by DavidAlfa
-
Initial Changelog file of DavidAlfa, available here as Changelog.md
-
Fixed a lot of bugs, lots of small improvements, specially the SPI DMA transfer
-
Much easier to port between devices
-
Commentary of changes in the forum thread - Posts starting here
- OLED Display
- Rotary Encoder
- Buzzer
- Wake switch
- Supply voltage sensor
- Ambient temperature sensor (might need calibration)
- Tip temperature read out (might also need calibration)
- T12 PWM Control (might burn your tip)
- I2C eeprom
- Docs have been split out into seperate 'docs' repo. Because the size of assets kept ballooning in git
- This repo is just only for source code now. This is simply code fork of PTDreamer meant for v2.1s Hardware
Well which Docs are you looking for?
- New Docs, Full Repo
- Backup of PTDreamer Blog
- Hardware Compatibility Docs
- How to Compile & Flash This Code with Official ST Toolchain
- Docs for Compiling / Flashing with VSCode and PlatformIO - TBD. Not done.