Including mktime() in MCF52235.mcp (CW v6.4)

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

Including mktime() in MCF52235.mcp (CW v6.4)

2,354 Views
lifestream
Contributor I
Hi,

I am trying to use the mktime() and localtime() functions in my MCF52235 project, however, I got a Linked Error saying that the functions are undefined even I had already include the <time.h>. Anyone has any idea to include such functions? Thanks in advance.


Best regards,
Chen Khoi

p/s: I am using CodeWarrior v6.4.
Labels (1)
0 Kudos
6 Replies

348 Views
CrasyCat
Specialist III
Hello
 
MSL library for embedded platform do not come with time function enabled per default.
Please refer to the manual {Install}\Help\PDF\MSL_C_Reference.pdf, chapter "Configuring MSL C" section "Configuring Time and Clock" for more information on how you can extend the library to support clock and time functions.
 
I hope this helps.
 
CrasyCat
0 Kudos

348 Views
lifestream
Contributor I
Hi CrasyCat,

Thanks for the direction. I try to modify the macro in "ansi_prefix.e68k.h" which sets

#ifndef _MSL_OS_TIME_SUPPORT
    #define _MSL_OS_TIME_SUPPORT    1
#endif

#ifndef _MSL_CLOCK_T_AVAILABLE
    #define _MSL_CLOCK_T_AVAILABLE     1
#endif

#ifndef _MSL_TIME_T_AVAILABLE
    #define _MSL_TIME_T_AVAILABLE    1
#endif

After I compile my file again, same "undefined" problem happened. Am I doing the right thing here? Can you show me how actually to extend the library? Thanks in advance.


Chen Khoi
0 Kudos

348 Views
CrasyCat
Specialist III
Hello
 
Well modifying the macros alone is not enough.
You have to provide an implementation of the time related function for your own board (platform).
 
CrasyCat
0 Kudos

348 Views
lifestream
Contributor I
Hi, sorry that I quite confuse on this (newbie).

When you mentioned "an implementation of the time related function on the board", are you saying that I need to implement my own time related functions? If yes, how can I utilize the "mktime()" and "localtime()" functions in the MSL lib?

Thanks for your help.

0 Kudos

348 Views
CrasyCat
Specialist III
Hello
 
I looked at this one a little bit more in detail.
Basically you need to do the following:
 1 - Create a new MSL library file, where _MSL_OS_TIME_SUPPORT, _MSL_TIME_T_AVAILABLE and  
    _MSL_CLOCK_T_AVAILABLE are set.
 2- Replace the MSL library file used in your project by the newly created one
 3- According to the file {Install}\Help\PDF\MSL_C_Reference.pdf, chapter "Configuring MSL C" section
     "Configuring Time and Clock" you need to provide your own implementation of following functions:
     __get_time, __to_gm_time, __to_local_time, __isdst and__get_clock. Please refer to the
    above stated manual to gather info on what these functions are actually doing.
 
For point 1 above I would proceed as follows:
  - Open the MSL library project. For MCF52235 it is
       {Install}\E68K_Support\msl\MSL_C\MSL_E68k\Project\MSL_C_CF_SZ.mcp file  
  - Check which MSL library you are currently linking in your project (C_4i_CF_SZ_MSL.a,
    C_TRK_4i_CF_SZ_MSL.a....)
  - Select the corresponding Build target (4i ColdFire SZ, TRK 4i ColdFire SZ, ...)
  - In the MSL library project window switch to the Target Tab
  -  Select "Project" -> "Create Target"
  - Specify a name for the new target and tell the IDE you want to clone the target you have identified
     above
  - Select the target target you have just create by clicking on the red target icon in front of the build
    target name. You should see a black arrow in the target.  
  - Open the target setting dialog (Type ALT + F7).
  - Switch to the "Coldfire Target" panel and specify a new name for the new library file (for example
     C_4i_CF_SZ_Time_MSL.a)
  - In the "C/C++ Preprocessor" panel, add following line: "#include <ansi_prefix_Time.h>"
  - Create the file ansi_prefix_Time.h by duplicating the file ansi_prefix.E68k.h and renaming it to
     ansi_prefix_Time.h.
  - In ansi_prefix_Time.h set _MSL_OS_TIME_SUPPORT, _MSL_TIME_T_AVAILABLE and  
    _MSL_CLOCK_T_AVAILABLE to 1.
  - Build the new library.
 
I would also specify  "#include <ansi_prefix_Time.h>" in your project's "C/C++ Preprocessor" panel.
I hope this helps.
 
CrasyCat
0 Kudos

348 Views
lifestream
Contributor I
Hi, It does help a lot and I am getting a better picture now. Many thanks.
0 Kudos