-
-
Notifications
You must be signed in to change notification settings - Fork 214
Open
Labels
Description
I'm trying this simple timer-related code, which is simplified from RPI pico SDK hardware_timer
//#include "pico/stdlib.h"
#include "pico/time.h"
volatile bool timer_fired = false;
int64_t alarm_callback(alarm_id_t id, void *user_data)
{
Serial.print("Fired. Timer");
Serial.println((int) id);
timer_fired = true;
// Can return a value here in us to fire in the future
return 0;
}
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println("TimerTest");
// Call alarm_callback in 2 seconds
add_alarm_in_ms(2000, alarm_callback, NULL, false);
// Wait for alarm callback to set timer_fired
while (!timer_fired)
{
tight_loop_contents();
}
Serial.println("Done");
}
void loop()
{
}
This code compiles OK using SDK or RP2040 arduino-pico core
But there are some issues with this core
- Missing
stdio.h
#include "pico.h"
#include "pico/stdio.h"
#include "pico/time.h"
but compiler finds no pico/stdio.h
in the core
In file included from /tmp/arduino_modified_sketch_904848/sketch_jun02d.ino:1:0:
/home/kh/.arduino15/packages/arduino/hardware/mbed_rp2040/2.1.0/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_stdlib/include/pico/stdlib.h:11:10: fatal error: pico/stdio.h: No such file or directory
#include "pico/stdio.h"
^~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Raspberry Pi Pico.
- Missing
time.c
Comment out
#include "pico/stdlib.h"
The compiler also generates error with this core, possibly no time.c
was included in the core
/home/kh/Arduino/Testing/RPi_Pico/Testing/Mbed_TimerInterrupt/Stdio_Issue/Stdio_Issue.ino: In function 'void setup()':
Stdio_Issue:24:3: error: 'add_alarm_in_ms' was not declared in this scope
add_alarm_in_ms(2000, alarm_callback, NULL, false);
^~~~~~~~~~~~~~~
/home/kh/Arduino/Testing/RPi_Pico/Testing/Mbed_TimerInterrupt/Stdio_Issue/Stdio_Issue.ino:24:3: note: suggested alternative: 'alarm_id_t'
add_alarm_in_ms(2000, alarm_callback, NULL, false);
^~~~~~~~~~~~~~~
alarm_id_t
exit status 1
'add_alarm_in_ms' was not declared in this scope
In time.h#L548-L549, the function add_alarm_in_ms
is declared as
static inline alarm_id_t add_alarm_in_ms(uint32_t ms, alarm_callback_t callback, void *user_data, bool fire_if_past) {
return alarm_pool_add_alarm_in_ms(alarm_pool_get_default(), ms, callback, user_data, fire_if_past);}
Regards,
ernesto75
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
khoih-prog commentedon Jun 2, 2021
I tried to change in defines.txt#L28 to
but still not OK yet.
Error
ernesto75 commentedon Jun 17, 2021
Confirmed, i cannot change the cpu clock speed on the pico with this simple sketch because of that error
Dresch123 commentedon Sep 6, 2021
I concur. Without the stdio.h file there does not seem to be any way to set the system clock with the Pico Pi. I posted this question a week ago but see that khioh-prog and ernesto75 posted it back in June. This seems like a handicap to the Mbed implementation.
Is there anyway to get the attention of the Mbed core developers concerning this? My attempts at adding the stdio.h from the Earle core have not been successful...
Thanks,
Bill
[-]Missing time.c and stdio.h files[/-][+][RP2040] Missing time.c and stdio.h files[/+]kylongmu commentedon Mar 9, 2022
Same problem, can't change sys clk. the version come to 2.8.0 , but this problem is still.