I've just started working with RPi Pico (RP2040), and I tried the following simple program:
#include <stdio.h> #include "pico/stdlib.h" volatile int chars_rxed = 0; int main() { stdio_init_all(); while (true) { printf("%d: chrx %d\n", to_us_since_boot(get_absolute_time()), chars_rxed ); sleep_ms(1000); } return 0; } I'm compiling on MINGW64 under Windows. Program compiles fine, then I plug the Pico pressing the BOOTSEL button, I get the "drive", and I copy the .uf2 result there.
Then, when the Pico reboots, I connect to its USB Serial port using tio - and this is the printout I get:
$ tio --baudrate 115200 --databits 8 --flow none --stopbits 1 --parity none /dev/ttyS6 [tio 13:04:18] tio v1.32 [tio 13:04:18] Press ctrl-t q to quit [tio 13:04:18] Connected 0: chrx 5005043 0: chrx 6005262 0: chrx 7005426 0: chrx 8005621 0: chrx 9005778 Considering the chars_rxed is always 0 in the code, it seems the printout reverses the order of arguments: so instead of printing to_us_since_boot(get_absolute_time()), chars_rxed, it prints chars_rxed, to_us_since_boot(get_absolute_time()).
But WHY? I've never seen this kind of a problem before ...
How can I get printf for Pico to print out the arguments as specified?