MQX 3.7 On MPC5125 Tower System Time Of Day Very Inaccurate

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

MQX 3.7 On MPC5125 Tower System Time Of Day Very Inaccurate

跳至解决方案
649 次查看
Tim562
Senior Contributor I

Hi All,

 

    I'm developing an app on a TWR-MPC5125 processor board and have found that the MQX system time loses about 1 second per minute of run time (Running under Ext Ram Debug from CodeWarrior). I have my app update the time using SNTP_oneshot() from time.nist.gov every 15 minutes and note how much time correction is required to get my MQX system time to agree with the SNTP server. My MQX system time is almost exactly 15 seconds slow at each update (5 seconds slow if I update every 5 minutes, etc). My application will need accurate time of day information to perform automation tasks at user programmed times (one second resolution is required).

 

     I'm wondering if this can be corrected (and if it's normal to have to correct it) by calling the MQX time_set_ticks_per_sec() function? Maybe the MQX time_set_resolution() function? In addition to the basic time functions I am using a 100mS timer interrupt in TIMER_ELAPSED_TIME_MODE to take care of various housekeeping tasks (maybe timers interfere with time of day?). I'm going to experiment some but if anyone has been through this before and could offer some advice that would be great. Thanks in advance. ~Tim

0 项奖励
1 解答
394 次查看
dwillett
Contributor I

Check your crystal frequency.  The schematics and MQX code call for 33.3M but some boards have a 32.768M crystal.  Update your linker files (.lcf) to use the correct frequency:

 

__EXTERNAL_CLOCK_SPEED = 32768000;

 

在原帖中查看解决方案

0 项奖励
3 回复数
395 次查看
dwillett
Contributor I

Check your crystal frequency.  The schematics and MQX code call for 33.3M but some boards have a 32.768M crystal.  Update your linker files (.lcf) to use the correct frequency:

 

__EXTERNAL_CLOCK_SPEED = 32768000;

 

0 项奖励
394 次查看
Tim562
Senior Contributor I

Your idea about why MQX time was slow was exactly correct. TWR-MPC5125 module has a 32.768 MHz crystal installed and the MQX linker control file specified 33.333MHz for the clock frequency. Corrected the LCF and the system now keeps perfect time! Thank you again for taking the time to respond. Happy holidays.

 

~Tim

0 项奖励
394 次查看
Tim562
Senior Contributor I

That's a real good thought, thank you I will check that out.

 

Regards,

Tim

0 项奖励