Re: Porting the Arduino millis(), possible?
Posted: Mon Mar 19, 2018 9:31 pm
Yes, there is a race condition. But I guess since the variable "g_last_tick" is only used to check for overflow of the timer -- to extend the resolution -- it's going to be in the resolution extension where any errors will be observed, so really it's every 43 seconds you could get some errors I suppose, assuming you call the function with some regularity. Honestly the shared globals don't really save anything, just a few bytes of RAM, so I don't know if it's worthwhile to take the risk. It's better for each core to have its own resolution extension. Each core that calls the function will use its own hardware timer (you can see that if you compile with -report) so I don't think there's any real benefit to the shared globals.
As for the long long, I didn't even know XC wasn't supposed to support 64 bit types. Otherwise I wouldn't have tried it. I am using xTIMEcomposer 14.3.2.
As for the long long, I didn't even know XC wasn't supposed to support 64 bit types. Otherwise I wouldn't have tried it. I am using xTIMEcomposer 14.3.2.