tubbutec Posted May 17, 2016 Report Posted May 17, 2016 Hi, had a look at the gfxSleepMicroseconds which is used by some drivers initialisation code. I believe the resolution is not in µs, in fact I would guess the actual delay for any value below 1000µs is a constant very small delay. This might actually cause troubles, if a small delay below 1ms is needed... from gos_x_threads.c: void gfxSleepMicroseconds(delaytime_t ms) { systemticks_t starttm, delay; // Safety first switch (ms) { case TIME_IMMEDIATE: return; case TIME_INFINITE: while(1) gfxYield(); return; } // Convert our delay to ticks delay = gfxMillisecondsToTicks(ms/1000); starttm = gfxSystemTicks(); do { gfxYield(); } while (gfxSystemTicks() - starttm < delay); } I don't have a good solution to create µs delays (yet), but the function is kind of misleading as it suggests it is able to perform µs delays...
inmarket Posted May 19, 2016 Report Posted May 19, 2016 It is exactly the same as any operating system delay function - the delay is affected by the resolution of the tick counter used by the operating system. A tick counter of 1ms will of course give a resolution of 1000us. There are only one way around this... 1. Hardware support for a more accurate timer that is busy polled with interrupts disabled. Operating system calls that pretend to offer high resolution timing without busy polling are lying as simply switching tasks is an expensive operation. So, as far as this routine is concerned both the required hardware support and the busy polling (with interrupts off) are a problem. In practice this routine is never used in any vanilla ugfx code. In the next major version of ugfx it will be removed.
tubbutec Posted May 20, 2016 Author Report Posted May 20, 2016 Thanks a lot for the insight. (and by the way thanks for developing this great library!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now