How to use the RT1:RealTime_LDD with FRDM-K64F

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

How to use the RT1:RealTime_LDD with FRDM-K64F

2,702 Views
neilporven
Senior Contributor I

I am using the KDS Version: 2.0.0; Eclipse Version: Kepler 4.3.2;  FRDM-K64F

So, I am trying to understand the KDS, PE, and Kinetis all at the same time, meanwhile trying to create

a small driver that other engineers in the company can use.  The first driver would be a clock (hours, minutes, seconds, milli-seconds).

I found that thru the component library, I can add components like the RT1:RealTime_LDD.

Under component help, I found the following code:

LDD_TDeviceData *MyRT1Ptr;

LDD_TError Error;

uint32_t i, time;

float one_loop_us;

void main(void)

{

MyRT11ptr = RT1_Init((LDD_TUserData *)NULL);

...

Error = RT1_Reset(MyRT1Ptr);

for (i = 0; i < 60000; ++i);

if (RT1_GetTimeUS(RT1_DeviceData, &time) == ERR_OK)

{

one_loop_us = time / 60000.0;

}

}

Instead of using RT1_GetTimeUS, I used RT1_GetTimeMS for milli-second.  I need to run my code in a 1ms loop.

I tried applying the code in my main.c and got some errors:

In the RT1_GetTimeMS(RT1_DeviceData, &time) == ERR_OK), it complained that RT1_DeviceData was undeclared?  Looking at the sample

code I noticed, that indeed RT1_DeviceData was not declared so I declared it as:  uint16_t RT1_DeviceData.  So, now I am getting two warnings

passing argument1 of 'RT1_GetTimeMS' makes pointer from integer without a cast[enabled by default].  I have no idea what this means or how to

correct it?

Why do they dived time/60000.0?

10 Replies

2,195 Views
neilporven
Senior Contributor I

I don't know how to execute this, but digging around, I find that the Kinetis SDK v.1.1 API Reference Manual has a RTC HAL driver and RTC Peripheral Driver.

I am still confused as to what is the relationship between PE, KSDK, and SDK? 

I understand the PE helps with setting up the processor registers without having to read a full manual and configuring things myself, which is awesome.

Can someone help me put the different pieces of the puzzle together?

For example: If I would like to use the RTC_HAL_SetDateTime() and GetDateTime() functions.  Due I need to add an #include in the main.c, (example: #include rtc.h)?  Where do I

place the typedef struct RtcDateTime? In a .h file that I create or in a .c file or somewhere else?

0 Kudos
Reply

2,195 Views
dafodil
Contributor III

Hi Niel,

Did you find a solution?

I got a problem that looks like yours.

My project is under K64F, I want to use a function from PE, GetTimeMS(), and my app crash each time it call GetTimeMS().

0 Kudos
Reply

2,195 Views
neilporven
Senior Contributor I

Hi Bernard,

This is what I have found so far.  If  you place your cursor over the GetTimeMS() method I found that its second argument &time is declared as a unsigned 32 bit interger, but in the example I found,  time is equated to a time structure which is 16 bits. I find this to be weird specially since the example was from a Kinetis PDF?  Hopefully I will have more clues for tomorrow.

If what your doing compiles then your at least one step in ahead.

0 Kudos
Reply

2,195 Views
dafodil
Contributor III

Hi,

I solved my problem with this post

https://community.freescale.com/message/427519#427519

It explain how to activate FPU on K64F.

I don't know why FPU was not activated.

0 Kudos
Reply

2,195 Views
neilporven
Senior Contributor I

Hi Bernard,

Congrats!

I am still having issues with my test.  I was able to make it compile, here is what I changed:

original was uint32_t i, time;   I changed it to uint16_t i, time;   This seems to have taken care of the compiling issue it was having, as I stated before.

Now, when I run the test program, I added a printf("The time is: %d \n", time); and printf("The ms loop is: %d \n", one_loop_ms);

the results are The time is: 57 and The ms loop is: 1062150445, it doesn't change, same answer over and over?  It doesn't complain or crash, but it doesn't

seem correct.  I am using the same example that's on the Help Real time measuring are you using the same or did you created something different?

Neil

0 Kudos
Reply

2,195 Views
DavidS
NXP Employee
NXP Employee

Hi Neil,

Fast update and will look into this more later.

I think the RealTime_LDD a bit too simplified for what you want to use it for.

I say that for following reasons (and maybe will update or change my mind later):

- the hardware used is FTM setup as a simple counter that via PE can have a customer resolution and/or period.

- it seems that the MS is what has the "better" time keeping as it is based off of the FTM "tick".

- it seems the US is just an extrapolation of the MS value so not really very accurate for the units.

- 16 bit resolution a bit (sorry for pun) weak

You might want to consider using the KSDK with PE and use the fsl_rtc RTC component.  It mostly does what you want minus the US units but in combinations of using a high resolution timer with it might meet your needs.

Regards,

David

0 Kudos
Reply

2,195 Views
neilporven
Senior Contributor I

Hi David,

So, this is what I did and its working.

I went to Component Library and under Logical Device Drivers, I found Timer, and under Timer, I found RTC_LDD.

I used RTC_LDD.  I used the example under the help and it worked.  I am thinking I should create a video that properly explains going from scratch to a time/date using this component.

I still don't know why would I choose the Timer located under Logical Device Drivers over the Timer located under CPU Internal Peripherals?  If you know can you explain this to me?

Thanks.

0 Kudos
Reply

2,195 Views
DavidS
NXP Employee
NXP Employee

Hi Neil,

Glad you found it and are up and running.

The Component Library tab in PE view has multiple ways to find a component. Not certain who set the rules or ordering but I too would think you would find RTC listed under the “CPU Internal Peripherals”.

PE in KSD has two modes of operation.

First is standalone and uses the LDD and Init_| components.

The difference is that the First method, the component once configured (without errors) is used to generate source code.

With the Second method, KSDK static code is used and the PE component just generates the configuration data/structures used by drivers.

These approaches are mutually exclusive (i.e. pick one approach only).

Reference:

C:\Freescale\KDS_2.0.0\eclipse\ProcessorExpert\KSDK_1.1.0_Eclipse_Update_Release_Notes.pdf – for the LDD and Init_| listing.

So from this I believe your code is based on “First” mode and not “Second” mode.

Hope this helps.

Regards,

David

2,195 Views
neilporven
Senior Contributor I

Thank you David.

0 Kudos
Reply

2,195 Views
neilporven
Senior Contributor I

Hi David,

I am using KSDK/w PE and I am trying to find the fsl_rtc RTC component you suggested, but I am not sure where it is located?

If I go to the Components Library: under CPU Internal Peripherals: under Timer, it doesn't appear!

If I go to the Components Library: under Logical Device Drivers; under Timer, I see RTC_LDD, but fsl_rtc doesn't appear!

Can you guide me as to where this is?  Is there a guide on how to use it?  that would help as well

Thank you.

0 Kudos
Reply