- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to code a timeout for making a loop non blocking using <time.h>.
I am in the EZUSB echosystem (no cmisys, ARM9269)
Please advice: here is the code exceprt
Thanks
#include <time.h> // are deines correct?
ErrorCode_t postReset(void)
{
cmd_reg_t _cmd;
uint8_t _trigger_ms = 10; /* 10ms */
const clock_t _before = clock();
{
const clock_t _delta = clock() - _before;
uint16_t _msec = _delta * 1000 / CLOCKS_PER_SEC; // CLOCK_PER_SECONDS is guarantee?
if (_msec > _trigger_ms)
{
_status = -1;
break;
}
_status = I2C_Read(sys_ctl.command_register.addr, 2, &(uint8_t)_cmd);
if(_status !=0 )
break;
} while (_cmd.ok !=1);
return _status;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can use CyU3PGetTime - Get the number of elapsed OS timer ticks since FX3 system start-up.
Each tick value is 1 ms.
Regards,
Sridhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Are you using Do While loop here?
I don't see where you put DO in the snippet.
If you want a delay, you can use CyU3PBusyWait or CyU3PThreadSleep.
Regards,
Sridhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I am using a do ... while (just forgot to copy and paste the do ....
I do not want a delay but I am trying to create a timeout in order not to 'block' the application
I wonder if CLOCK_PER_SECONDS macro (==10 which seems to me a too small value ...) is reliable (I see EZUSB example code does not use CMSIS and the system timer but I understand the SoC is based on the good old 926 and not on a cortex)
Thanks much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can use CyU3PGetTime - Get the number of elapsed OS timer ticks since FX3 system start-up.
Each tick value is 1 ms.
Regards,
Sridhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks much. This solve my problem
One last question; which RTOS is used? It is derived from freeRTOS or what? I'd like to access some documentation about it
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It is ThreadX RTOS.
regards,
sridhar