"printf" stops working when GPIO is used in ADC application

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

"printf" stops working when GPIO is used in ADC application

跳至解决方案
2,528 次查看
mykepredko
Contributor IV

Hiya,

 

This is a bit of a strange one, but it seems like "printf" statements stop working in an ADC application.  In the attached application, I have put in a cut down MQX "ADC" example which has optionally included GPIO statements. 

 

It seems that when the :

 

fopen("gpio:write", ...

 

executes, the "printf" statement no longer sends out data on UART0. 

 

To test it, define "mdebug" to show how the application works normally (with the Pot voltage value output on the console) and then change "mdebug" to something else and the GPIO statements will be inserted (along with the evb's four LEDs being turned on/off by the operation of the pot/adc) but printfs stop working.  You'll notice that I have repeated the first printf statement to show that printf stops working after the fopen APIs. 

 

I used an M52223EVB to test this out with CW10 and MQX 3.6 (rebuilt to include ADC and GPIO active). 

 

Any ideas?  Can anybody see what I'm doing wrong?

 

Thanx,

 

myke

0 项奖励
回复
1 解答
1,579 次查看
JuroV
NXP Employee
NXP Employee

Your stack in the main task is overflowed. Increase stack size of the main task.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
1,580 次查看
JuroV
NXP Employee
NXP Employee

Your stack in the main task is overflowed. Increase stack size of the main task.

0 项奖励
回复
1,579 次查看
mykepredko
Contributor IV

Hi Juro,

 

That was it - thank you.  It really is something I should have caught on my own. 

 

Is there any way to determine how much stack is being used/is required for a task? 

 

myke

0 项奖励
回复
1,579 次查看
JuroV
NXP Employee
NXP Employee

Search for topic "MQX - Task Stack Size" in this forum.

0 项奖励
回复
1,579 次查看
mykepredko
Contributor IV

Hey Juro,

 

I presume you mean the comment by BugMan:

 

I use kernel logging features, enable by  MQX_KERNEL_LOGGING and MQX_MONITOR_STACK (needs to compile MQX libraries),  then use _klog_show_stack_usage() in your application to output messages on stdout device, it gives an idea about stack memory consumption.

 

I'll try it - thanx for the pointer.

 

myke

0 项奖励
回复