cancel
Showing results for 
Search instead for 
Did you mean: 

Non Blocking programming

techdesk
Associate III

I have a STM32F411 board connected with a GPS module connected onto USART2
I also have Tim1 and Tim3 configured for PWM generation on their channels respectively.

I am running a list of commands (from an array) to execute line for line.

Most of the execution is in the form of assigning new values to the Timer channels

Eg: __HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2, motor1_speed); Motor speed is a variable assigned from the list. As the program executes the list (by iterating  line for line, these variables get assigned those values.)

The GPS on the other hand is being polled via USART2

The problem is that I need both the execution of the array as well as the GPS to continue running.

However, the array execution is causing a "blocking issue". I have about 15 lines of instructions in the executing array. The GPS will only work AFTER ALL the commands of the array has been executed due to its blocking issue.

I investigated from many sources who advised:

  1. Use RTOS - this did not work. It still blocks
  2. Use another Timer to run the GPS. - Still did not work.

Any assistance here?

23 REPLIES 23

In the OP, @techdesk wrote:
 

the array execution is causing a "blocking issue"


Still no idea what that means, why it had a "blocking issue", nor how specifically you solved that.

If you understand STM32 programming my answers will be spot on.
I am afraid that I cannot relate further to non-programmers. 

LOL - says the guy who was moaning about people giving advice but not providing example code!

This isn’t about not providing code—I have absolutely no problem sharing it if you ask. However, my code would be useless if you don’t understand how to use it effectively.

Let me emphasize: this project represents a significant feat for anyone attempting to program autonomous systems.

My setup involves a simple quadcopter controlled via PWM generation timers. If anyone is working on something similar, I’m happy to provide relevant code snippets. However, sharing the entire project wouldn’t be practical because I don’t know how you’re controlling your motors. For example, most drone enthusiasts use a multi-channel radio (6–10 channels).

I don’t. My system uses a LoRa module and a laptop to send commands via serial radio to a custom control board (an STM32F411CE in this case). Once a list of commands is uploaded, the quadcopter can:

  • Take off autonomously.
  • Transmit its current GPS location.
  • Receive additional commands from me via LoRa during flight.

This is a very advanced project with a lot of other code involved. I would NEVER recommend this to beginners or even average programmers—it’s highly complex. That said, I’m not here to discourage anyone! If you’re an experienced programmer, you likely don’t need my code to implement your own solution.

The only reason I came here was to troubleshoot a minor bug, which has since been resolved. It turned out to be a simple mistake.