STM32 Blue Pill (STM32 F103C8) powered Ebike controller made for the Silicon Valley Clean Energy Ebike Competition. This program is developed in conunction with the PlatformIO system, a substantial upgrade from the oxymoron Arduino IDE.
Relevant Peripherals:
- MPU6050 6DOF Accelerometer and Gyroscope (in GY521 breakout board via I2C)
- VESC 4.12 via UART communication
- SD Card breakout board via SPI
Unfortunately, at the time of writing, the stock MPU6050_tockn
library has an issue when built for the STM32 F103C8. To fix this, the calls to wire->requestFrom
in the library's code must be changed by removing the last (int)true
parameter wherever it appears.
i.e.: wire->requestFrom((int)MPU6050_ADDR, 14, (int) true);
--> wire->requestFrom((int)MPU6050_ADDR, 14);
NOTE: This is currently fixed in the local version of the MPU6050_tockn
library. No need to make any changes.
These changes are addressed as of MOU6050_tockn@>1.5.1
.
For some reason, the default STSTM32
linker scripts for the generic STM32F103C8
, the chip on the Blue Pill, assume that the the MCU has 64K of program flash memory, which is just not the case, as most boards around have 128K of flash. This shouldn't be an issue, but for the extra headroom, this is a good mod. Original post on PlatformIO Community forum.
File | Original | Post-mod |
---|---|---|
[USER_DIR]\.platformio\platforms\ststm32\boards\genericSTM32F103C8.json |
"maximum_size": 65536, |
"maximum_size": 131072, |
[USER_DIR]\.platformio\platforms\ststm32\ldscripts\stm32f103x8.ld |
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K |
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K |