I am using a MCF54418 with MQX 3.8.1, when I am updating the time using _time_set() then read immediately after using time_get() the times do not match, the get time is still the time from up (usually a few seconds) where as I tried setting the seconds to 1356048000. Can anyone possibly shed some light on this? Thank you in advance.
Solved! Go to Solution.
I found the issue, it actually was due to something a coworker commited, for some reason they removed the add_ticks part to get_time, so it only ever returned the time from the start. Not sure why they did that yet, but that is what happened, thanks for your help!
Hello Kevin davis,
can you share some code, project or at least code snippet, just to be sure I test the same scenario which you have been having problems. It makes an entire process faster. Thank you.
Regards,
MartinK
Oh sure thing, sorry I prolly should have thought of it. This first part is from my main,
TIME_STRUCT mqx_time;
mqx_time.SECONDS = 1356048000;
_time_set(&mqx_time);
_time_get(&mqx_time);
printf("seconds = %i",mqx_time.SECONDS);
This always prints 0 for seconds. when it should be printing what I set it to right above, 1356048000. I traced it as far into the PSP as I can understand, and I see some values change in the kernel, but I don't necessarily know how to tell if its doing that correctly.
I notice you are not looking at the return values. I suspect the "_time_set()" at line 3 is failing. I see 2 errors in your code. 1) you are using an uninitialized value from the stack. 2) incorrect value for printf format string
The code should look like:
You are correct about those other errors, and I have changed those with no impact, however mqh.h defines the functions as follows
extern void _time_get(TIME_STRUCT_PTR);
extern void _time_set(TIME_STRUCT_PTR);
Hello Kevin Davis,
I tested this on K60 because I do not have currently MCF board available, and it worked as expected. This is basic functionality which must work out of box, there was one bug in _psp_ticks_to_time but that does not have any impact on your result.
Check locals in your debugger if there's really 0 in TIME_STRUCT :smileywink:
Regards,
MartinK
I know, thats why its so strange, and it was working the other day, could I have changed something in the BSP to disable the time functions or something along those lines?
Also here is the value of the time struct after get
mqx_time | 0x440089e8 | 0x440089e8 | ||
SECONDS | 0 | 0x440089e8 | ||
MILLISECONDS | 25 | 0x440089ec |
I found the issue, it actually was due to something a coworker commited, for some reason they removed the add_ticks part to get_time, so it only ever returned the time from the start. Not sure why they did that yet, but that is what happened, thanks for your help!