Hi all,
I'm using the MQX Lite on my FRDM KL25Z.
I'm having a problem with printf inside a loop. This is the code:
void Initial_task(uint32_t task_init_data)
{
uint32 ptr;
#ifdef DEBUG
for(ptr = 0; ptr < 10; ptr++)
{
printf("\n"); //Clear terminal
}
printf("\n< start >\n\n");
#endif
HardwareInitialize();
printf("\n> Hardware Initializated\n");
SetAudio(2);
for(;;)
{
int i;
if (LED_GetVal())
{
printf("\nLED on");
_time_delay_ticks(2000);
}
}
The printf inside the "for" isn't working. When I run that code, the program stops at PE_ISR(Cpu_ivINT_Hard_Fault).
I can make it work by removing the printf function from loop. But, why that isn't working at this loop?
Thanks
Hello Wenderson.
can you please upload your demo project here? I will test it.
Please also let me know your CW version: Start the IDE and click on Help | About CodeWarrior Development Studio. Send me the version and build id.
ZhangJun
Does it work if you put the loop after the HardwareInitialize() call? It may be that the HardwareInitialize turns on the clock gating for the UART module, and if you try to use the UART module before that it would cause a hard fault like you're seeing. Try moving it to after it.
-Anthony
Hi Anthony
Sorry, I did not express myself correctly... the "printf" that isn't working is from the second "for". The hardware initialize function just set IO ports, the UART module is initialized by PEx.