Printf not working correctly for MQX_Lite?

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

Printf not working correctly for MQX_Lite?

1,724 次查看
Amit_Kumar1
Senior Contributor II

Hi

I am using codewarrior 10.5. I have created a new MQX Lite project. In that I am using Console_IO PE component. When I tried printing string it works well. When I tried printing integer values, I noticed some strange behavior. i.e

1. "\n" is not working when using at the end of a string.

2. For the following program, the values are coming abruptly

         

void Init_task(uint32_t task_init_data)

{

int i;

     while(1)

      {

          printf ("i = %d\n", i++);

           _time_delay_ticks(1000);

      }

}

the o/p I am getting in terminal window is

serial.jpg

I am using K60 uc. The above o/p is for one shot. i.e it repeats each time after _time_delay_ticks(1000);

I found one document MQX_IO drivers. http://cache.freescale.com/files/32bit/doc/user_guide/MQX_IO_User_Guide.pdf   on page no 16, there are functions for IO so for printf we can use _io_printf but that is giving an error.

How do I fix this issue. Initially I will be displaying the data in terminal window later I will be storing the values in SD card. But if this error persists then It won't be possible. Please look into this matter.

Kind Regards

Amit Kumar

标记 (5)
0 项奖励
回复
5 回复数

1,390 次查看
karelm_
Contributor IV

Hi,

you have to initialize variable i like this:

int i = 0;

Also it is better to use \r\n as line ending.

printf ("i = %d\r\n", i++);

Best regards,

Karel

0 项奖励
回复

1,390 次查看
Amit_Kumar1
Senior Contributor II

Hi Karel

I made a new MQX lite project and checked. I have attached the project. I think the uc is restarting. I wrote the same code for without MQX project and that is working fine. here the o/p is

serial.jpg

0 项奖励
回复

1,390 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Amit,

TWR-K100D100M in CW10.6 works fine. See attached project,

Regards,

Carlos

0 项奖励
回复

1,390 次查看
Amit_Kumar1
Senior Contributor II

Hi Carlos

I figured the issue but don't know how to resolve it. While debugging, The progrm was going to PEDebughalt (the uc was restarting)so on further investigation I found the issue was of _time_delay_ticks(100); on removing this line and using WAIT component of Erich Styger resolved the issue. One more issue I had was I wanted to print floating values to terminal so I used the following configurations.

config.jpg

So these 2 issue were there, which made the uc to restart.

The program I have attached had the _time_delay_ticks(100); issue.

The Floating point setting was found in the other program(MQX_Lite based). So my concern is how to resolve these issue? as I want ms level precision in my project and I will be logging data in SD card with ms i.e HH:MM:SS:ms format so I was thinking of using the system timer 1 i.e

1.jpg

I dont want to switch to codewarrior 10.6 as there are some issues with it  Is there a bug in PE of codewarrior 10.6?

Kind Regards

Amit Kumar

0 项奖励
回复

1,390 次查看
Amit_Kumar1
Senior Contributor II

Hi Karel

thanks for quick response  I followed your instructions. I think the device is restarting by it self.

the result is as following

serial.jpg

Kind Regards

Amit Kumar

0 项奖励
回复