Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[RP2040] Missing time.c and stdio.h files #250

Open
Labels
@khoih-prog

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

  1. Missing stdio.h

In stdlib.h#L10-L12

#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.
  1. 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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /