print time and date with FRDM-KL25Z board

cancel
Showing results for 
Search instead for 
Did you mean: 

print time and date with FRDM-KL25Z board

1,033 Views
mikeconover
Contributor II

I have the FRDM-KL25Z board and I am trying to print the current time and date to the console using the TimeDate_LDD driver. Right after the time and date are printed to the console it gets stuck in the routine below. Has anyone ever seen this problem and know how to fix it??

PE_ISR(Cpu_Interrupt)

{

  /* This code can be changed using the CPU component property "Build Options / Unhandled int code" */

  PE_DEBUGHALT();

}

0 Kudos
6 Replies

512 Views
BlackNight
NXP Employee
NXP Employee

Hi Mike,

I suggest you enable 'own for every' so you know which interrupt fired (see "Oh my! An Interrupt… | MCU on Eclipse").

Are you using the RTC? In that case, the common cause for a hard fault is

- RTC is not powered, make sure that the RTC pins are powered (schematics)

- That the clock gates are enabled.

I hope this helps,

Erich

0 Kudos

512 Views
mikeconover
Contributor II

Erich,

After enabling the interrupts to every, it goes to the Cpu_ivINT_Hard_Fault. I read all your posts about tracking down a hard fault with no luck.

Yes, I am using the RTC module inside the chip. I am using the FRDM-KL25Z board. I don't see any power pins for the RTC. Am I missing something?

The clock gates are enabled. 

It seems that the RTC is working because when I have a breakpoint set in the OnSecond event, I see it go there every second. When I add the printf to the code below is when I get the hard fault. Can you see what I am doing wrong?

LDD_TError Error;

LDD_TimeDate_TDateRec MyDate;

LDD_TimeDate_TTimeRec MyTime;

Error = TD1_GetTime(TD1_DeviceData, &MyTime);              /* Get current time */

Error = TD1_GetDate(TD1_DeviceData, &MyDate);              /* Get current date */

printf("Current hour is %d",MyTime.Hour);

Thanks,

Mike

0 Kudos

512 Views
mikeconover
Contributor II

The problem looks to be with the printf function. Why would printf cause a hard fault? Anyone else have this problem?

-Mike

0 Kudos

512 Views
mikeconover
Contributor II

I guess I will just use the ConsoleIO driver.

-Mike

0 Kudos

512 Views
mikeconover
Contributor II

Nevermind. I get the same exact problem when using the ConsoleIO driver. Whenever I add a second argument that isn't a string to printf it is not happy and throws a hard fault. I tried the line below and it doesn't work and gets stuck in the hard fault interrupt. :smileysad:

printf("Hello World %d \r\n",4);

Any ideas how to print a number?

Thanks,

Mike

0 Kudos

512 Views
BlackNight
NXP Employee
NXP Employee

Hi Mike,

I suspect you run into a stack overflow or heap problem. Printf() and its friends are very problematic in my view, see the links below.

Anyway, as you still desire to use it, I have attached an example project for the KL25Z using Kinetis Design Studio.

It asks for a name and a number, and prints it to the OpenSDA USB CDC connection:

pastedImage_4.png

Links to the printf() topic:

I hope this helps,

Erich

0 Kudos