Printf error on MQX Lite

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Printf error on MQX Lite

1,497 次查看
wendersonolivei
Contributor IV

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

标记 (2)
0 项奖励
回复
4 回复数

1,246 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复

1,246 次查看
wendersonolivei
Contributor IV

Hi Zhang

I'm using CW 10.6,  Build Id:140329.

A demo project with this same error is attached.

Regards

0 项奖励
回复

1,246 次查看
anthony_huereca
NXP Employee
NXP Employee

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

0 项奖励
回复

1,246 次查看
wendersonolivei
Contributor IV

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.

0 项奖励
回复