Skip to main content
Visitor II
May 21, 2024
Solved

Suggestions for better blue pill performance

  • May 21, 2024
  • 4 replies
  • 2625 views

Hello,

i am working for now on a diy project.

In this project i am interfacing LoRa SX1278 (SPI), MPU6050 (I2C) and NEO-6M (UART) with the STM32F103C8 (blue pill).

All in all it is working but because all this sensors and modules are served in the loop, it is affecting the speed of the µC.

I am thinking of using Free RTOS for that purpose.

The goal is that every 10 - 15 seconds the STM32 reads  NEO-6M and packs the results in a Buffer to send it with LoRa to the receiver.

Would free RTOS be a good idea?

Any suggestion is appreciated.

Thanks in advance

    This topic has been closed for replies.
    Best answer by Peter BENSCH

    As mentioned by @Andrew Neil this thread relates to a so-called Blue Pill, which uses illegally cloned STM32F103. ST resources are only dedicated to supporting genuine ST products. We are not committed to ensuring that clones/fakes products work properly with the firmware we provide.

    We recommend to purchase genuine products from STMicroelectronics and purchase them from known and trusted distributors.

    This thread will now be locked. However, if you face difficulties while using genuine ST products, we’re here to assist you. Please feel free to start a new thread, and our team, along with community members, will be ready to help you with any issues/questions you encounter.

    Thank you for your understanding.

    Regards
    /Peter

    4 replies

    Super User
    May 21, 2024

    @hamo wrote:

     STM32F103C8 (blue pill).


    On a Blue Pill, that is (almost?) certainly not a genuine ST STM32F103C8.

     


    @hamo wrote:

    because all this sensors and modules are served in the loop, it is affecting the speed of the µC.


    It's only two sensors - that really shouldn't be any problem at all!

    What "speed" are you achieving ?

    Why do you consider this "too slow" ?

    Investigate where your bottlenecks are.

    Just bolting-on an RTOS won't magically speed this up!

     

    EDIT:

     


    @hamo wrote:

    The goal is that every 10 - 15 seconds the STM32 reads  NEO-6M and packs the results in a Buffer to send it with LoRa to the receiver.


    You'd need to be careful that you don't exceed the maximum allowed time-on-air...

     


    @hamo wrote:

    NEO-6M (UART)


    You mean this: https://www.u-blox.com/en/product/neo-6-series ?

    hamoAuthor
    Visitor II
    May 21, 2024

    Thank you for the reply.

    It affects the transmission because it reads the NEO-6M and then decode the result in the same while loop where transmitting the data occurs.

    Therefore i thought of using free RTOS so it can do this tow tasks parallel? i think.

    The transmission with LoRa i am working on it may be for a future radio controller for a UAV i am intending to make (maybe).

    The main goal is not to affect the transmission.

    One more important mission in the while loop is writting the received data to the timers (PWMs).

    So all  these tasks in a while loop is delaying somehow the transmission.

    I want these three tasks:

       1- receiving and retransmitting data,

       2- reading uart and decoding and

       3- write to the timers to be parallel if possible

    Graduate II
    May 21, 2024

    Data from.the NEO-6M could be collected and buffered on IRQ Handler

    Graduate II
    May 21, 2024

    I suspect busy waiting is the problem. I don't think there are calculations that would take up significant time at 72MHz. There could be a delay in some function, or polling for a ready signal on a chip until it's ready, or waiting until a serial transaction of a peripheral is completed. Replace busy waiting by polling or interrupts should solve the problem. Basically you need to turn these busy waiting functions into statemachines that return when it's waiting for something and can continue where they left of by saving the state (you can use a switch statement). An RTOS could help you with that, because it essentially turns every thread into a statemachine (by saving the instruction pointer and stack), but you still need to use RTOS delays, yields or semphores so the RTOS knows when it can or must switch between threads. An RTOS adds some overhead and uses more memory, and you can achieve the same thing with less overhead by using a polling loop and interrupts.

    My advice is to draw a simple timing diagram of your code. Use a logic analyzer to check timing. You can log the serial inputs and outputs and also toggle some spare GPIO pins at certain places in the code. That way you can visualize and quantify all your timing.

    hamoAuthor
    Visitor II
    May 21, 2024

    Thank you all for your suggessions and advices.

    I will surely work on them and see how can i achieve my goals.

    Technical Moderator
    April 25, 2025

    As mentioned by @Andrew Neil this thread relates to a so-called Blue Pill, which uses illegally cloned STM32F103. ST resources are only dedicated to supporting genuine ST products. We are not committed to ensuring that clones/fakes products work properly with the firmware we provide.

    We recommend to purchase genuine products from STMicroelectronics and purchase them from known and trusted distributors.

    This thread will now be locked. However, if you face difficulties while using genuine ST products, we’re here to assist you. Please feel free to start a new thread, and our team, along with community members, will be ready to help you with any issues/questions you encounter.

    Thank you for your understanding.

    Regards
    /Peter