Hi,
i am using LPC 2132 and LPC 2134 as microcontrollers. Is there a way to print current time/system time on console logs.
Does your system maintain a "current time/system time" ?
yes it does.
please tell me if their is a way to print current time.
Does your system have a printer?
"yes it does" is a very bad answer to the question if your system do maintain the current date/time.
How does it do it? That should tell you how you can get access to the time.
You only have three items to solve. - how to get access to the time (given that it does exists and gets updated somewhere), something we can't help you with since you have told us nada about your project. - how to format it into presentable characters. This differs if you store the time in unix epoch (seconds since 1970-01-01 00:00) or as broken-down year, month, day of month, hours, minutes, seconds, or if your clock is storing the time in some other format. We obviously don't know anything about how your project stores/updates the time. - how to emit these characters to a serial port, 7-segment digits, LCD or whatever you have. Obviously, the used hardware affects how to do it, and we don't know anything about your hardware.
So why do you ask us questions, when you don't supply any information at all about your project and your goals? We can't read minds...
Hi, Sorry if u didn't get my question. Actually i m not very experienced and thought this is a silly problem known by an experienced person.
What i m doing is : i m using LPC 2132 as microcontroller and have programmed it in C. C functions like time() or get_time_of_day etc don't execute on this MC and same is the problem with system(x) command. So, it will be very helpful if u people can tell me if their is a way to get current time.
And the first question you got was "Does your system maintain a "current time/system time" ?"
That is a relevant question.
You can't pick up a time using any CRTL functions, unless you do have a time maintained somewhere. Do you have a battery on the board, and drive the RTC (Real Time Clock) device in the processor? If you do, then you need code to set the initial time in the RTC. Similar code would then also be able to retrieve the time from the RTC.
Or do you have an external RTC using I2C? Same there - you need code to set the time of the RTC and similar code may then be able to retrieve the time too.
Keil can't supply you with CRTL functions to get the time since there are no generally available clock in embedded devices.
If you look at the manuals for the CRTL, they mention specifically functions that you need to write yourself, if you want to incorporate clock functionality in the CRTL.
The C standard library includes code that can convert between an integer in Unix epoch into individual fields year/month/day-of-month/hour/min/sec or reverse. But you need a place to store that ticking secounds counter that time() is intended to return.
But how did you expect us to know that?
Remember, nobody knows anything about you, your experience, your project, etc, other than what you clearly & explicitly state in your posts!
There are some good books to study here: http://www.keil.com/books
Also look out for training opportunities with local suppliers; eg, http://www.keil.com/events/
NXP have a lot of training materials on their website, YouTube, through their distributors, etc...
"C functions like time() or get_time_of_day etc don't execute on this MC"
No functions run on any platform unless they have been loaded onto it!
With a PC, you have a vast amount of support from Windows or Linux or whatever;
On an embedded microcontroller, you have to provide it all - either by writing it yourself, or by including 3rd-party code.
The Compiler Manuals tell you what support is provided by the compiler's own libraries (its run-time libraries; RTL) - and what support you need to provide yourself to enable those functions to work. Keil call this Retargetting.
Keil's Manuals are available online here: http://www.keil.com/support/man_arm.htm
There are lots of supporting resources here: http://www.keil.com/support/