Some Information on the BluePill (STM32F103C)

Below are some observations one might encounter when working with the STM32F103C as a micronctoller in conjunction with the Arduino STM32 library. A good secondary source for documentation s Leaflabs Maple.

Some of these details here are specific to a certain STM32F103C model, such as the LED pin. The following information should be used to guide, rather than to follow directly.

Electrical

  • The onboard LED is on pin PC13. Lights up when the output for this pin is LOW.
  • Has an onboard 3.3V voltage regulator. This drops input power from the 5V pin and from USB to 3.3V
  • Operates on 3.3V, rather than 5V on an Arduino.
  • The Blue Pill's 5V regulator is not the best in the world, especially when sourced from cheap Chinese sites, so don't expect the Blue Pill to be able to run a lot of LEDs or Servos. The stock 3.3V regulator can handle up to 300mA.

Pinout

More Pin Info

  • Non-5V tolerant pins will be damanged when receiving a voltage near 5V.
  • Pins PA9 and PA10 are used to interface with the USB to TTL adapter. However, you should not need to do this. (e=read the seciton on Uploading)
  • Pins PC13, PC14, PC15 are to be used if crucially needed. These pins cannot sink or source a lot of current. Damage to these pins could result in damage to the internal oscillators and the real time clock.
  • Pin PB2 is useable, but placed in an awkward position.
  • Pins marked ADC support analogRead() and pinMode(PIN, INPUT_ANALOG). These pins are 12-bit, so the range is 0 to 4096.
  • Pins can be 'softly' pulled up to 3.3V or down to ground with the pin modes INPUT_PULLUP or INPUT_PULLDOWN with the use of internal 22k resistors. Example: If INPUT_PULLUP is used, the state will be high unless an external device is specifically pulling the pin down to ground. The “gentle” pull up will not affect the state of the input.
    • This is best used for digital inputs.
    • INPUT is the same as INPUT_FLOATING
  • To enable PWM output on PA11, we must give up serial over USB, since one of the USB data signals is mapped to this pin. To do this, comment out all the contents in void USBSerial::begin(void) in usb_serial.cpp located in .platformio\packages\framework-arduinoststm32\STM32F1\cores\maple
  • PA12 is HIGH when the Blue Pill is turned on (before any code execution).

Software

  • With PlatformIO and the Arduino STM32 library, the Blue Pill can be used very similary to an Arduino. Follow these instructions to get up and running.
  • One can use the traditional pinModes by using itegers such as pinMode(13, OUTPUT), but it is recommended to use enums pinMode(PA3, OUTPUT).
  • It is possible to iterate over a set of pins by iterating through the enums:
enum {
    PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13,PA14,PA15,
    PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13,PB14,PB15,
    PC13, PC14,PC15
};

Uploading

  • To have the system be able to detect the serial device over USB, download the Arduino STM32 repo, navigate to \drivers\win and execute the install_drivers.bat script.
  • Once done, the Blue Pill should show up in Device Manager as a Maple Serial device.
  • Ensure that platformio.ini has the appropriate settings (Load with your COM port):
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_port = COM8
upload_protocol = dfu
  • Upload the sketch from PlatformIO. The IDE will attempt to set the Blue Pill into DFU mode to upload the sketch. If this fails, or it is stuck, simply hit the RESET button on the Blue Pill when PlatformIO is searching for DFU devices.
    • Becuase USB uploading does not require moving BOOT0 to 1, resetting the Blue Pill will only provide a short window to allow the IDE to upload the sketch.

Using Motors and Servos Simultaneously

This information is applicable for when the microcontroller is used to switch motors and to control servos using the default libraries.

When servo.attach() is called on a certain pin, the hardware timer responsible for creating the PWM signal is set to a certain period/frequency. On the Blue Pill, this period/frequency is synchronized across all pins that the timer is responsible for. So if you have a motor running on the same timer as a servo but another motor running on a different motor, the motor speeds will differ because their PWM frequencies will differ.

One fix is to coordinate pinouts such that all motors run on their own timer, but usually we can't afford this luxury so we turn towards a different solution, by synchronizing all of the timers to be the same.

void timerSetup() {
    for (int i = 1; i <= 4; i++) {
        HardwareTimer timer(i);
        timer.pause();
        timer.setPeriod(20000);
        timer.refresh();
        timer.resume();
    }
}

A period of 20 milliseconds is chosen because this is the period that servo.attach() sets the pins to.

Motors and Sensing

Motors add noise to the system, and this brings about bad news if the pins are floating.

When using limit switches, since the states can be interpreted digitally, the appropriate pinmode should be INPUT_PULLDOWN.

When using analog inputs, it is desirable to be stopped when reading to minimize noise. Other electrical and mechanical considerations can also reduce noise.

Fourier Transform of a Generic Gaussian A Hackintosh Experience as a Long Time Windows User
 

Add a comment

Comments

Boss, My name is Richard. I am one of your customers. remember me? I think your business should be on google maps, apple maps and Bing maps. Benefits include instant SEO, Brand positioning and trust, Unlimited foot traffic, unlimited online traffic and phone calls. I wanted to connect you with United States marketing company They can help you. https://bit.ly/unitedstatesmarketing You can call/Text/Whatsapp them on 14427327888 Best regards Richard George clutch
Written on Sun, 15 Sep 2024 02:08:16 by Richard George
Still looking to get your WordPress website done, fixed, or completed? Reach out to us at e.solus@gmail.com & Prices starts @ $99!
Written on Thu, 12 Sep 2024 07:11:15 by Lois Daigre
Payroll, Insurance, inventory, marketing EXPENSES ……UGHH Want to remove the stress and get some breathing room? Get a no obligation working capital quote in less than 2 minutes. == Must Be A US Based Business To Qualify == Send me a message at my contact info below for info Elizabeth Miller elizabeth.miller@helloratesfastfunding.com https://www.helloratesfastfunding.com
Written on Wed, 11 Sep 2024 14:16:34 by Winfred Ellison
Hey Not sure how much money donneyfan.com is making, but selling digital products is on fire. The transaction value in the Digital Commerce market is projected to reach US$7.63 trillion in 2024. (Statistica.) There is a simple 2-step method to make money selling high-profit, digital products in less than an hour per day. Start leveraging from this growing economy. Learn how here: https://hoply.io/Q5QNX
Written on Tue, 10 Sep 2024 22:21:43 by Odessa Kuhn
Hey there, ready to take your ad game to the next level? Imagine your message popping up in website contact forms all over the world, reaching heaps of potential customers! Starting at just under $100, our affordable packages pack a punch. Shoot me an email now to chat more about getting your brand out there! Let's make some noise together! Phil Stewart Email: nuv8tq@submitmaster.xyz Skype: form-blasting
Written on Sun, 23 Jun 2024 01:50:50 by Phil Stewart
Who said running a business was easy? Especially when the cost of nearly everything continues to skyrocket. Cut yourself a break from the stress of rising expenses with a working capital solution that will provide you the relief needed to get through these challenging times. Get a no obligation working capital quote in less than 2 minutes. ** USA Based Businesses Only! ** Get in touch with me below for more info Elizabeth Miller elizabeth.miller@helloratesfastfunding.com https://www.helloratesfastfunding.com
Written on Sat, 22 Jun 2024 15:52:32 by Dario Cribbs
Hi there, We run a YouTube growth service, which increases your number of subscribers both safely and practically. We go beyond just subscriber numbers. We focus on attracting viewers genuinely interested in your niche, leading to long-term engagement with your content. Our approach leverages optimization, community building, and content promotion for sustainable growth, not quick fixes. Additionally, a dedicated team analyzes your channel and creates a personalized plan to unlock your full potential, all without relying on bots. Our packages start from just $60 (USD) per month. Would this be of interest? Kind Regards, Emily
Written on Fri, 21 Jun 2024 23:11:58 by Emily Jones
The Vetted Business Directory has completed its May 2024 updates with 7,358 new businesses added. Your business was unfortunately NOT ABLE TO BE INCLUDED :-( Don’t worry, this is easy to fix. Use the link in my signature to add or update your Vetted business details and realize the powerful benefits of being a Vetted Business in your local market, your service category and your business specialty. Yours in trust & transparency, Sarah McCormick Vetted Business Specialist 295 Seven Farms Drive Suite C-201 Charleston, SC 29492 Sarah.McCormick@VettedPros.com https://vettedpros.com/1-2/?a=Get-Your-Business-Vetted! Vetted is a game changing platform used by over 85,000 USA based businesses to share & prove their business credentials to amplify trust & transparency with shoppers and close up to 60% more sales than businesses not listed on the Vetted platform.
Written on Wed, 19 Jun 2024 21:44:33 by Lisette Gertz
Just like you've received this message: Broadcast your message to numerous email inboxes starting at USD9. We will send your message through countless website contact forms, guaranteeing all messages land the inbox. Generate potential customers, traffic, customers, and brand awareness. Visit https://bit.ly/cformmarketing Unsubscribe here if you don't want to get these awesome offers: https://bynd.li/unsubscribe Kopfholzistrasse 16, Lavin, NA, Switzerland, 7543
Written on Tue, 18 Jun 2024 03:27:23 by Gus Alaniz
If you are reading this message, That means my marketing is working. I can make your ad message reach 5 million sites in the same manner for just $50. It's the most affordable way to market your business or services. Contact me by email virgo.t3@gmail.com or skype me at live:.cid.dbb061d1dcb9127a
Written on Mon, 17 Jun 2024 20:21:36 by Mark Hansford
Hi there, We run a YouTube growth service, which increases your number of subscribers both safely and practically. We go beyond just subscriber numbers. We focus on attracting viewers genuinely interested in your niche, leading to long-term engagement with your content. Our approach leverages optimization, community building, and content promotion for sustainable growth, not quick fixes. Additionally, a dedicated team analyzes your channel and creates a personalized plan to unlock your full potential, all without relying on bots. Our packages start from just $60 (USD) per month. Would this be of interest? Kind Regards, Emily Unsubscribe: https://removeme.click/yt/unsubscribe.php?d=donneyfan.com
Written on Mon, 17 Jun 2024 19:14:41 by Emily Jones
Finally, an easy way to offer affordable payments to ALL customers and credit grades Don't leave money on the table, now you'll be able to turn people with low credit scores into paying customers! == Must Be A US Based Business To Qualify == Send me a message at my contact info below for info Jessica Snyder jessica.snyder@helloratespros.com https://helloratespros.com/5-6/
Written on Sun, 21 Apr 2024 05:12:08 by Tanesha Lonergan
Hello there! I hope this email finds you well! I couldn't help but notice that your website could be getting more traffic. Don't worry; I've got just the solution to skyrocket your online presence! I recently stumbled upon an incredible opportunity tailored specifically for small businesses like yours: https://tinyurl.com/bigmoney10off And here's the best part - I've secured an exclusive 10% discount just for you! Simply use the code "BigMoney" at checkout to claim your savings. This offer is too good to pass up. Imagine the possibilities for your business once you implement the strategies outlined in this ebook! Don't miss out on this opportunity to take your business to new heights. Grab your copy today and watch your website soar! Warm regards! PS: Remember, this exclusive discount won't last forever. Act now to secure your savings and unlock the full potential of your website! Check it now: https://tinyurl.com/bigmoney10off
Written on Fri, 19 Apr 2024 14:21:45 by Garry Kuster
Boost Your Videos with Submagic - The Best AI Tool for Short-Form Content Hey there, Are you tired of spending hours creating captions, searching for the perfect transitions, and adding sound effects to your videos? Submagic is here to save the day! Elevate your content creation game with Submagic, the ultimate AI tool for short-form content. Take your videos to the next level with our easy-to-use features that will save you time and money. Don't waste any more time on manual video editing tasks when Submagic can do it all for you in seconds. Trusted by over 500k creators and businesses, including big names like Grant Cardone and David Goggins. Whether you're a content creator, video editor, or business owner, Submagic has everything you need to create engaging videos that stand out. Try Submagic now and see the difference it can make in your content creation process. click here: https://stopify.co/I00GIF Generate captions, add B-rolls, create dynamic transitions, highlight key moments with Auto-Zoom, include sound effects, and generate video descriptions all with the power of AI. Testimonial: "Submagic has revolutionized my video editing process. It's a game-changer!" - Jason, Happy Submagic User Sign up for Submagic today and discover why it's the go-to tool for creators worldwide. https://stopify.co/I00GIF Don't miss out on the opportunity to streamline your video editing process with Submagic. Join the thousands of creators already using Submagic and transform your videos today. https://stopify.co/I00GIF Humorous P.S.: Who needs a magic wand when you have Submagic? Try it out and see the magic happen! Let Submagic take your videos from ordinary to extraordinary. Sign up now and unleash your creativity! Best regards, Mark, Submagic Team
Written on Fri, 19 Apr 2024 13:18:08 by Houston Frith
Finally, an easy way to offer affordable payments to ALL customers and credit grades More approvals = More Profits == Must Be A US Based Business To Qualify == visit: https://helloratespros.com/5-6/ OR email me here: jessica.snyder@helloratespros.com
Written on Thu, 18 Apr 2024 22:21:04 by Alica Perivolaris
Have a business you want to get off the ground but lack the funding? I can invest, email me here: info@financeworldwidehk.com
Written on Thu, 18 Apr 2024 19:08:03 by Ahmad Mayers
Are rising business expenses and the cash flow roller coaster causing you stress? Who said running a business was easy? Especially when the cost of nearly everything continues to skyrocket. Cut yourself a break from the stress of rising expenses with a working capital solution that will provide you the relief needed to get through these challenging times. Get a no obligation working capital quote in less than 2 minutes. *I can only help US businesses* Send me an email here to find out more: elizabeth.miller@helloratesfastfunding.com Elizabeth Miller Working Capital Loan Specialist 295 Seven Farms Drive Suite C- 201 Charleston, SC 29492 www.HelloRatesFastFunding.com elizabeth.miller@helloratesfastfunding.com
Written on Mon, 15 Apr 2024 17:57:32 by Julieta Bradberry