BluePill: Difference between revisions
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
The BluePill is an inexpensive Arduino style microcontroller board built around the STMicroelectronics ARM Cortex-M3 STM32F103CT6 microcontroller. | The BluePill is an inexpensive Arduino style microcontroller board built around the STMicroelectronics ARM Cortex-M3 [https://www.st.com/resource/en/datasheet/stm32f103rc.pdf STM32F103CT6] microcontroller. | ||
[[File:BluePill pinout.png|frameless|501x501px]] | [[File:BluePill pinout.png|frameless|501x501px]] | ||
== Specifications == | |||
The 32-bit microcontroller runs at 72MHz, has 20k of RAM, 128k of flash, and a shitload of GPIO pins. At around $5 each, it's basically superior to all the Arduino options, at a fraction of the price. | The 32-bit microcontroller runs at 72MHz, has 20k of RAM, 128k of flash, and a shitload of GPIO pins. At around $5 each, it's basically superior to all the Arduino options, at a fraction of the price. | ||
VBAT/5V can accept from 3 - 5VDC. | |||
3V3 pins can alternatively be used to power the chip directly (nothing on the board requires 5V) | |||
3V3 pins can alternatively be used to power the chip directly | |||
VBAT is not connected directly to USB P+. '''Do not power it from one of the pins and from the USB port at the same time.''' | VBAT is not connected directly to USB P+. '''Do not power it from one of the pins and from the USB port at the same time.''' | ||
The digital I/O pins are 5V tolerant so long as you don't use the internal pullups. The analog ADC is, of course, not 5V tolerant. Best just stick to 3v3 for everything if you can. | |||
== Flashing == | |||
The USB port is basically useless. | The USB port is basically useless. | ||
* Connect a TTL-Serial adapter connected to UART1 (Pins PA9 & PA10 above, A9 A10 on the silkscreen). | |||
* Set the "boot" jumper (top) to 1 (rightmost position). | |||
* Press the [RESET] button | |||
* Start your upload | |||
''The program will execute immediately upon uploading, but not upon reset until you set the "boot" jumper back to 0.'' | ''The program will execute immediately upon uploading, but not upon reset until you set the "boot" jumper back to 0.'' | ||
=== '''PlatformIO Configuration''' === | |||
'''PlatformIO Configuration | |||
''platform: ststm32; board: bluepill_f103c8; framework: arduino'' | ''platform: ststm32; board: bluepill_f103c8; framework: arduino'' | ||
'''platformio.ini''' settings using arduino framework and TTL Serial Upload:<syntaxhighlight lang="ini"> | |||
[env:bluepill_f103c8] | |||
platform = ststm32 | |||
board = bluepill_f103c8 | |||
framework = arduino | |||
upload_protocol = serial | |||
upload_port = /dev/ttyUSB0 # correct as needed | |||
</syntaxhighlight> | |||
== '''GPIOs''' == | |||
PA0 - PA15, PB0 - PB15, PC13 - PC15. | |||
The Arduino library references them directly by name (e.g. PA0). | |||
Any IO pin can be an interrupt driver, and there are '''16''' external interrupts configurable. | |||
[https://www.electronicshub.org/working-with-interrupts-in-stm32f103c8t6/ Good reference on interrupts on the STM32F103C8T6] | |||
=== '''Analog Measurement (0-3v3)''' === | |||
The 10 analog input pins are '''12-bit''' resolution (0-4096 int). | |||
'''Analog (0- | |||
The 10 analog input pins are 12-bit resolution. | |||
Analog inputs: PA0 - PA7, PB0, PB1 | Analog inputs: PA0 - PA7, PB0, PB1 | ||
=== '''PWM Output''' === | |||
'''PWM Output | There are 15 PWM outputs total. | ||
There are 15 PWM | |||
PA0 - PA3, PA6 - PA10, PB0 - PB1, PB6 - PB9 | PA0 - PA3, PA6 - PA10, PB0 - PB1, PB6 - PB9 | ||
''!! First set the PWM settings for the chip in your setup():''<syntaxhighlight lang="c"> | |||
''!! First set the PWM settings for the chip in your setup():'' | analogWriteResolution(8); # of bits of PWM resolution, max 16 bits | ||
analogWriteFrequency(1000); # PWM frequency in Hz, max unknown | |||
< | </syntaxhighlight>Then you can use <code>analogWrite(PIN, VALUE)</code> as per usual. | ||
Then you can use <code>analogWrite(PIN, VALUE)</code> as per usual. | |||
''N.B.: If you want to drive a PWM output from an analog reading, you can just set the analogWriteResolution to 12 and then you don't have to map the values!'' | ''N.B.: If you want to drive a PWM output from an analog reading, you can just set the analogWriteResolution to 12 and then you don't have to map the values!'' | ||
=== Miscellaneous === | |||
The user-definable LED on the board is sink-ground through PC13. Set PC13 LOW to turn it on. '''Note: PC13 is not a PWM output.''' | The user-definable LED on the board is sink-ground through PC13. Set PC13 LOW to turn it on. '''Note: PC13 is not a PWM output.''' | ||
Latest revision as of 13:15, 25 January 2025
The BluePill is an inexpensive Arduino style microcontroller board built around the STMicroelectronics ARM Cortex-M3 STM32F103CT6 microcontroller.
Specifications
The 32-bit microcontroller runs at 72MHz, has 20k of RAM, 128k of flash, and a shitload of GPIO pins. At around $5 each, it's basically superior to all the Arduino options, at a fraction of the price.
VBAT/5V can accept from 3 - 5VDC.
3V3 pins can alternatively be used to power the chip directly (nothing on the board requires 5V)
VBAT is not connected directly to USB P+. Do not power it from one of the pins and from the USB port at the same time.
The digital I/O pins are 5V tolerant so long as you don't use the internal pullups. The analog ADC is, of course, not 5V tolerant. Best just stick to 3v3 for everything if you can.
Flashing
The USB port is basically useless.
- Connect a TTL-Serial adapter connected to UART1 (Pins PA9 & PA10 above, A9 A10 on the silkscreen).
- Set the "boot" jumper (top) to 1 (rightmost position).
- Press the [RESET] button
- Start your upload
The program will execute immediately upon uploading, but not upon reset until you set the "boot" jumper back to 0.
PlatformIO Configuration
platform: ststm32; board: bluepill_f103c8; framework: arduino
platformio.ini settings using arduino framework and TTL Serial Upload:
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_protocol = serial
upload_port = /dev/ttyUSB0 # correct as needed
GPIOs
PA0 - PA15, PB0 - PB15, PC13 - PC15.
The Arduino library references them directly by name (e.g. PA0).
Any IO pin can be an interrupt driver, and there are 16 external interrupts configurable.
Good reference on interrupts on the STM32F103C8T6
Analog Measurement (0-3v3)
The 10 analog input pins are 12-bit resolution (0-4096 int).
Analog inputs: PA0 - PA7, PB0, PB1
PWM Output
There are 15 PWM outputs total.
PA0 - PA3, PA6 - PA10, PB0 - PB1, PB6 - PB9
!! First set the PWM settings for the chip in your setup():
analogWriteResolution(8); # of bits of PWM resolution, max 16 bits
analogWriteFrequency(1000); # PWM frequency in Hz, max unknown
Then you can use analogWrite(PIN, VALUE) as per usual.
N.B.: If you want to drive a PWM output from an analog reading, you can just set the analogWriteResolution to 12 and then you don't have to map the values!
Miscellaneous
The user-definable LED on the board is sink-ground through PC13. Set PC13 LOW to turn it on. Note: PC13 is not a PWM output.