LPC55S6x Connecting the RTC to newlib time.h using _gettimeofday()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC55S6x Connecting the RTC to newlib time.h using _gettimeofday()

520 Views
Jelle
Contributor I

Hello,

I am trying to connect the onboard rtc of the LPC55S69 to the time.h functions in newlib:

I have tried defining my own _gettimeofday() function based on this forum post as follows:

#include "LPC55S69_cm33_core0.h"
#include "fsl_common.h"
#include "fsl_rtc.h"

#include <time.h>
#include <reent.h>
#include "assert.h"

int _gettimeofday_r(struct _reent *pReent, struct timeval *tp, void *tzvp)
{
	assert(pReent != NULL);
	assert(tp != NULL);

	if (tp)
	{
		tp->tv_sec = RTC_GetSecondsTimerCount(RTC); // get the seconds from a clock source
		tp->tv_usec = 0; // get the microsconds from a clock source
	}

	return 0;
}

int _gettimeofday(struct timeval *tp, void *tzvp)
{
	return _gettimeofday_r(_impure_ptr, tp, tzvp);
}

However it seems to create the following error(s):

Description Resource Path Location Type
c:/nxp/mcuxpressoide_11.7.1_9221/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.7.1.202301190959/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v8-m.main+fp/hard\libcr_newlib_semihost.a(syscalls.o): in function `_gettimeofday': firmware C/C++ Problem

Description Resource Path Location Type
first defined here firmware line 59 C/C++ Problem

Description Resource Path Location Type
make: *** [makefile:115: all] Error 2 firmware C/C++ Problem

Description Resource Path Location Type
make[1]: *** [makefile:124: firmware.axf] Error 1 firmware C/C++ Problem

Description Resource Path Location Type
make[1]: Target 'main-build' not remade because of errors. firmware C/C++ Problem

 

Is this not the correct way to define this function?

Labels (2)
0 Kudos
2 Replies

475 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I am not familiar with the newlib timer, I can not find out the file either

reent.h

Can you attach the reent.h file so that we can have a test.

BR

Xiangjun Rong

0 Kudos

450 Views
Jelle
Contributor I

Hi,

The reent.h file is supplied by the newlib library in the mcuxpresso SDK.

The original source can be found in the newlib github repository:

https://github.com/eblot/newlib/blob/master/newlib/libc/include/reent.h

On my machine it can be found at:
C:\nxp\MCUXpressoIDE_11.7.1_9221\ide\plugins\com.nxp.mcuxpresso.tools.win32_11.7.1.202301190959\tools\arm-none-eabi\include

 

0 Kudos