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??
/* This code can be changed using the CPU component property "Build Options / Unhandled int code" */
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,
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?
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);
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?
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:
Links to the printf() topic:
I hope this helps,