RTC integration

asked Dec 9, 2019 in System Integration by Mike_PPsys
Hi Gents,

I'm looking to integrate a TI BQ32000 RTC with EW. I've updated EwBspConfigRealTimeClock() and EwBspGetTime() as needed. And EwBspConfigRealTimeClock() kicks off via ewmain.c

But how is EwBspGetTime() suppose to get called?

1 Answer

0 votes
answered Dec 10, 2019 by Manfred Schweyer

Hi Mike,

the RTC is read by using the function EwBspGetTime(). This function is called from the function EwGetTime() which is implemented in the RunTime Environment module ewextrte.c. You can access the current time from your GUI application by using the property CurrentTime of the class Core::Time.

Best regards,


commented Dec 10, 2019 by Mike_PPsys
Ok, so EwGetTime() is called when I access Core:Time's CurrentTime property?
commented Dec 10, 2019 by Manfred Schweyer
Yes, exactly!
commented Dec 10, 2019 by Mike_PPsys

Oh, I think I just realized why I'm so perplexed. I was testing this with a WebGL build.

I have debug as follows:

unsigned long EwBspGetTime( void )
    return 1234567890;


But, "TestText.String = string(currentTime.Time);" keeps giving me back 1575989xxx. As WebGL is pulling currentTime.Time not from the BspGetTime() but from the local OS. Right?

I'll have to poll EpochTime over Websocket and Time.Initialize{} ... ?

commented Dec 10, 2019 by Manfred Schweyer
Yes - that's also correct.... ;-)

My answer was valid for MCUs - in case of WebGL or Linux based MPUs usually the system time is used. I thought your question (where you mentioned EwBspConfigRealTimeClock() and ewmain.c) was referring to MCUs.

In case of Javascript/WebGL, the system time (where the browser is running) is used.

Does this answer your question? In case you have Javascript/WebGL running in a browser and you want to get the time of an RTC from an embedded system (e.g. including a webserver), you can implement your own GetCurrentTime() method within the GUI application and query the time via native code.
commented Dec 10, 2019 by Mike_PPsys
Yeah, I'm doing both types of builds so I easily get confused some days heh.

How do I get the WebGL/JS code to stop querying the OS? So that I can impliment my own Websocket based GetCurrenTime() to stuff Core::Time with the MCU's EpochTIme.
commented Dec 10, 2019 by Manfred Schweyer

In case you are using the latest version of Embedded Wizard (V9.30) you can create a variant from the class Core::Time and implement your own getCurrentTime() method. With older versions this is not possible.

Alternatively, you can derive your own Time class with your own platform sepcific getCurrentTime() method and use that instead of the Core::Time class.

commented Dec 10, 2019 by Mike_PPsys

Ok, upgraded to 9.30 and created a variant. Then updated the getCurrnentTime() method:

$if !$prototyper && ( $platform == *.WebGL.* )
Device.HMI_GetTime(); // calls my Websocket code and stuffs Device.HMI_time with unix epoch
result = Device.HMI_time;

But I keep just getting 0 from currentTime.Time:

var Core::Time currentTime = Time.CurrentTime;

SecondText.String = string(currentTime.Time);

I know HMI_time (uint32) is being stuffed... do I need to do a cast on it before stuffing it into var result ?


commented Dec 10, 2019 by Mike_PPsys
Thought maybe this was because I'm looking at currentTime.Time in Init{} and thats before Owner and subDialog have been created. ... But I created InitSlot{} and called it with idlesignal InitSlot; from Init{} and still no luck.
commented Dec 10, 2019 by Mike_PPsys
Oh, the issue must be that the Websocket code isnt returning quick enuogh for getCurrnentTime(). And, therefore, still reads 0 and stuffs 0 into result. What's the best way to handle this poll and wait situation with  getCurrnentTime() ?
commented Dec 11, 2019 by Manfred Schweyer
In this case it is not sufficient to overwrite getCurrentTime() - this class expects a synchroneous RTC call. Furthermore, I think you will not get the "real time" in this scenario.

Maybe you should implement and use your own Time class, that sends the request and that updates the GUI when the answer is received.

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