Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 4 months ago.
Cannot find input file "global.h"
Hi, I have downloaded your library (i.e. RTC for the DS1307).
I'm importing it and creating the RTC object as follow:
- include "DS1307.h" DS1307 Rtc_Ds1307(p9, p10); using LXP 1768
However I'm getting the following error: Error: Cannot open source input file "global.h": No such file or directory in "RTC/rtc.cpp", Line: 16, Col: 21
Can you tell me what's happening here? (obviously global.h is missing... but where to I find it?)
Question relating to:
1 Answer
9 years, 4 months ago.
Sorry, this was an error in the library, the global.h file is not needed. Please update the library and try again.
The correct way to create the object is like so:
rtc lib init
#include "ds1307.h" I2C i2c(p9, p10); DS1307 Rtc_Ds1307(i2c);
Hi,
I made a quick program (see below). While I do not have the "global.h" error anymore, it is still not working.
Using both method of setTime (either using int, int, int or using a time_t) does not make any difference. The RTC always return 0hr, 0min, 0s.
The program below produce the following results (print in the terminal) (using an LXP1768):
## Starting the program
Time as seconds since January 1, 1970 = 1256729737
Mbed Time (Since last boot): 0.001465
Time as a basic string = Wed Oct 28 11:35:37 2009
Hour: 0, min: 0, sec: 0 Mbed Time (Since last boot): 0.517275 Time as a basic string = Wed Oct 28 11:35:37 2009
Hour: 0, min: 0, sec: 0 Mbed Time (Since last boot): 1.033610 Time as a basic string = Wed Oct 28 11:35:38 2009
Hour: 0, min: 0, sec: 0 Mbed Time (Since last boot): 1.549964 Time as a basic string = Wed Oct 28 11:35:38 2009
Hour: 0, min: 0, sec: 0 Mbed Time (Since last boot): 2.066319 Time as a basic string = Wed Oct 28 11:35:39 2009
Code:
- include "mbed.h"
- include "ds1307.h"
DigitalOut myled(LED1); Serial pc(USBTX, USBRX);
I2C i2c(p9, p10); DS1307 Rtc_Ds1307(i2c);
uint8_t* hour; uint8_t* min; uint8_t* sec;
int main() {
pc.printf("## Starting the program
\r\n");
Set the RTC of the mbed set_time(1256729737); Set RTC time of Mbed to Wed, 28 Oct 2009 11:35:37 time_t time_t_seconds = time(NULL); pc.printf("Time as seconds since January 1, 1970 = %d\r\n", time_t_seconds);
Set the mbed timer (since last boot time) Timer mbded_timer; mbded_timer.start();
Set the time of the external RTC (DS1307) Rtc_Ds1307.setTime(8, 33, 2); Rtc_Ds1307.setTime(time_t_seconds);
while(1) {
Rtc_Ds1307.getTime(hour, min, sec); time_t time_t_seconds = time(NULL); pc.printf("\r\n"); pc.printf("Mbed Time (Since last boot): %f\r\n", mbded_timer.read()); pc.printf("Time as a basic string = %s\r\n", ctime(&time_t_seconds)); pc.printf("Hour: %d, min: %d, sec: %d\r\n", hour, min, sec); myled = 1; wait(0.2); myled = 0; wait(0.2); } }
posted by 10 Aug 2015
@clemrom: The library doesn’t yet work with the mbed set_time function. You will have to call rtc.set_time and rtc.time to set/get time.
posted by Per J. G. 11 Aug 2015