758 views
in System Integration by
Hi,

I use the object Core::Time for the realtime clock. I implement the function EwGetTime and now return the second since epoch and everything work.

Updating the library I overwrite the ewextrte.c file and lost the modified EwGetTime.

In order to not modify the library file is possible to have a global variabile returned by EwGetTime and my application assign a value to this variable?

Or if you use gnu gcc add a attribute weak to EwGetTime declaration so I can re define a new EwGetTim in my application code and use it instead of library function?

void __attribute__((weak)) EwGetTime(void) {...}

1 Answer

+1 vote
by
 
Best answer
Hi Michele,

thank you for your proposal.

We are just introducing an access to the RTC via the module BoardConfig.c. This means that the ewextrte.c file will just contain a function call, that will not change after future updates.

I think this is what you want to ensure.

Best regards!
by
In the STM32 ew:bsp_clock.c the algorithm in EwBspGetTime

give me a wrong date

assuming to set the date to 2017-01-01   00:00:00

the application show me 2016-12-31 00:00:00

any suggestion?
by
Hi,

which Build Environment are you using?

Does your main.c file contains the initialization of the RTC?

Please check if there is the initialization of the RTC included (via function call EwBspConfigRealTimeClock()).
by
I'm using the BSP board config version you sent me a couple of week ago.

I'm working with the KEIL_ARM compiler, but the problem is a conversion error in the function EwBspGetTime()

In order to solve the bug the line:

days = (year + 30) * 365 + (year + 24 + 1) / 4;

became

days = (year + 30) * 365 + (year + 24 + 1) / 4 + 1;

Do you confirm?
by
Hi Stefano,

you are right, there is a bug in the calculation of the days since 01.01.1970.

The correct calculation is: days = (year + 30) * 365 + (year + 27) / 4;

   30 years (1970..1999) without additional leap year days

+ leap year days begining from 1972 (year + 28 - 1)  / 4

The -1 is because we have to add the additional day one year after the leap year.

This will work till year 2100 which is exceptioally no leap year.
by
This will be changed within our Build Environments for coming Embedded Wizard V8.20.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...