This repository contains source code for the STM32F[0-1]xx, used in the Matrix Keypad to CAN interface PCB. The keypad pad presses are decoded and transmitted over a CAN bus network as ASCII characters.
The only matrix keypad decoders that I could find at the time transmitted the data over RS232. I needed to connect multiple keypads to a single PLC communications port and this is not possible because RS232 only supports two devices on the same bus. RS232 has other limitations like single ended signalling which limits transmission length. The PLC had a CAN bus port that I could connect multiple keypads to so I designed a matrix keypad to CAN decoder interface PCB.
This repo is a PlatformIO project. The code can be built by folllowing these steps:
- Install PlatformIO by following this guide: https://platformio.org/install/ide?install=vscode
- Clone the repo with
git clone <repo/url> - Build and upload the code with
platformio upload
All microcontrollers in the STM32F0xx and STM32F1xx series with at least 32kB of flash are theoretically supported. Very little testing has be done and only on the STM32F042F6.
STM32 F 042 F 6 P 6 xxx
| | | | | | | |
| | | | | | | |
Device family_______________________________________| | | | | | | |
STM32 = ARM-based 32-bit microcontroller | | | | | | |
| | | | | | |
Product Type______________________________________________| | | | | | |
F = general-purpose | | | | | |
| | | | | |
Device subfamily_______________________________________________| | | | | |
0x0 = Value line | | | | |
0x1 = Access line | | | | |
0x2 = USB line | | | | |
0x8 = Low Voltage line | | | | |
103 = performance line | | | | |
| | | | |
Pin count___________________________________________________________| | | | |
F = 20 pins | | | |
G = 28 pins | | | |
K = 32 pins | | | |
T = 36 pins | | | |
S = 44 pins | | | |
C = 48 pins | | | |
R = 64 or 66 pins | | | |
V = 100 pins | | | |
Z = 144 pins | | | |
| | | |
Flash memory size_______________________________________________________| | | |
4 = 16 Kbytes of Flash memory | | |
6 = 32 Kbytes of Flash memory | | |
8 = 64 Kbytes of Flash memory | | |
B = 128 Kbytes of Flash memory | | |
C = 256 Kbytes of Flash memory | | |
D = 384 Kbytes of Flash memory | | |
E = 512 Kbytes of Flash memory | | |
| | |
Package_____________________________________________________________________| | |
P = ISOOP | |
H = BGA | |
U = VFQFPN | |
T = LQFP | |
Y = WLCSP64 | |
| |
Temperature range_______________________________________________________________| |
6 = Industrial temperature range, -40 to 85°C |
7 = Industrial temperature range, -40 to 105°C |
|
Options______________________________________________________________________________|
xxx = Programmed parts
TR = Tape and real
| Header File | MCU Part Number |
|---|---|
| STM32F042F4, STM32F042G4, STM32F042K4, STM32F042C4 | |
| stm32f042x6.h | STM32F042F6, STM32F042G6, STM32F042K6, STM32F042T6, STM32F042C6 |
| ----------------- | ---------------------------------------------------------------------- |
| STM32F103T4, STM32F103C4, STM32F103R4 | |
| stm32f103x6.h | STM32F103T6, STM32F103C6, STM32F103R6 |
| ----------------- | ---------------------------------------------------------------------- |
| STM32F103T8, STM32F103C8, STM32F103R8, STM32F103V8 | |
| stm32f103xb.h | STM32F103TB, STM32F103CB, STM32F103RB, STM32F103VB |
| ----------------- | ---------------------------------------------------------------------- |
| Signal Name | F042F4 Pin |
|---|---|
| K_1 | PA04 |
| K_2 | PA05 |
| K_3 | PA06 |
| K_4 | PA07 |
| K_A | PA00 |
| K_B | PA01 |
| K_C | PF01 |
| K_D | PF02 |
| USART2_TX | PA02 |
| USART2_RX | PA03 |
| CAN_RX | PA11 |
| CAN_TX | PA12 |
| CAN_LED | PB06 |
| BUZZER | PB01 |
| SWDIO_STM | PA13 |
| SWCLK_STM | PA14 |
To enable the socket CAN interface on Linux, run the following commands: $ ip link set dev can0 up type can bitrate 250000 $ candump can0