Hi guys,
I am trying to use Threads in my nucleo rb072rb, but it seems it is not working, when I compile project from PIO.
When I try to compile the same code over Mbed online compiler - it works great.
Could you please assist?
Here is my code:
#include "mbed.h"
const size_t a_stk_size = 1024;
uint8_t a_stk[a_stk_size];
Thread a_thread(osPriorityNormal, a_stk_size, &a_stk[0]);
const size_t b_stk_size = 1024;
uint8_t b_stk[b_stk_size];
Thread b_thread(osPriorityNormal, b_stk_size, &b_stk[0]);
const size_t c_stk_size = 1024;
uint8_t c_stk[c_stk_size];
Thread c_thread(osPriorityNormal, c_stk_size, &c_stk[0]);
const size_t d_stk_size = 1024;
uint8_t d_stk[d_stk_size];
Thread d_thread(osPriorityNormal, d_stk_size, &d_stk[0]);
Serial pc_serial(USBTX,USBRX);
static void thread_a(void)
{
uint32_t execs = 0;
printf("## started thread_a execution! ##\n\r");
for(;;) {
execs++;
wait(2);
printf("## thread_a executed %d times! ##\n\r", execs);
}
}
static void thread_b(void)
{
uint32_t execs = 0;
printf("## started thread_b execution! ##\n\r");
for(;;) {
execs++;
wait(2);
printf("## thread_b executed %d times! ##\n\r", execs);
}
}
static void thread_c(void)
{
uint32_t execs = 0;
printf("## started thread_b execution! ##\n\r");
for(;;) {
execs++;
/* adds dummy processing */
wait(2);
printf("## thread_c executed %d times! ##\n\r", execs);
}
}
static void thread_d(void)
{
uint32_t execs = 0;
printf("## started thread_a execution! ##\n\r");
for(;;) {
execs++;
wait(2);
printf("## thread_d executed %d times! ##\n\r", execs);
}
}
int main(void)
{
pc_serial.baud(9600);
a_thread.start(thread_a);
b_thread.start(thread_b);
c_thread.start(thread_c);
d_thread.start(thread_d);
}
I tried to use several mbed/ststm32 versions and result is the same.
Processing nucleo_f072rb (platform: ststm32@4.4.0; board: nucleo_f072rb; framework: mbed)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_f072rb.html
PLATFORM: ST STM32 > ST Nucleo F072RB
HARDWARE: STM32F072RBT6 48MHz 16KB RAM (128KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 26 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <mbed-rtos>
|-- <mbed-mbedtls>
Checking size .pioenvs/nucleo_f072rb/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA: [========= ] 93.3% (used 15280 bytes from 16384 bytes)
PROGRAM: [===== ] 51.0% (used 66896 bytes from 131072 bytes)
====================================================================================================== [SUCCESS] Took 4.31 seconds ======================================================================================================
Terminal will be reused by tasks, press any key to close it.