1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<TITLE>OS_*SecondsToTicks*</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">OS_*SecondsToTicks* <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1> 12<H2>Syntax</H2> 13<DL> 14 <DD> 15 <PRE><CODE>#include <nitro/os.h></CODE></PRE> 16 <PRE><CODE>#define OS_MicroSecondsToTicks( microSec ) 17#define OS_MicroSecondsToTicks32( microSec ) 18 19#define OS_MilliSecondsToTicks( milliSec ) 20#define OS_MilliSecondsToTicks32( milliSec ) 21 22#define OS_SecondsToTicks( sec ) 23#define OS_SecondsToTicks32( sec ) 24 25(These are all macros.)</CODE></PRE> 26</DL> 27<H2>Arguments</H2> 28<TABLE border="1" width="100%"> 29 <TBODY> 30 <TR> 31<TD width="13%"><EM><STRONG>sec</STRONG></EM></TD> 32<TD width="87%">Seconds</TD> 33 </TR> 34 <TR> 35<TD width="13%"><EM><STRONG>milliSec</STRONG></EM></TD> 36<TD width="87%">Milliseconds</TD> 37 </TR> 38 <TR> 39<TD><EM><STRONG>microSec</STRONG></EM></TD> 40<TD>Microseconds</TD> 41 </TR> 42 </TBODY> 43</TABLE> 44<H2>Return Values</H2> 45<P>The tick value that corresponds to the time specified by the argument.</P> 46<H2>Description</H2> 47<P>This function obtains the tick value that corresponds to the time specified by the arguments.</P> 48<P>One tick unit is 1/64 of the system clock.</P> 49<P><CODE>OS_MicroSecondsTo Ticks*()</CODE> converts microseconds to tick values.<BR><CODE>OS_MilliSecondsToTicks*()</CODE> converts milliseconds to a tick value.<BR><CODE>OS_SecondsToTicks*()</CODE> converts seconds to a tick value.<BR>These functions are all defined as macros.</P> 50<P>Functions with <CODE>32</CODE> in their names conduct 32-bit internal calculations. Those without <CODE>32</CODE> conduct 64-bit calculations. 32-bit versions handle smaller values than 64-bit versions, so they cannot always return correct results because of overflow. However, when there is no overflow, they have the advantage of keeping the code smaller, making operating speed faster. However, since the degree of difference is not that great, and to prevent bugs, we recommend you use functions that do not include <CODE>32</CODE> in the name. Furthermore, when a constant is made into an argument, it is calculated just before compiling and the resulting value is also a constant.</P> 51 52<P>When operating in 32-bit mode, be careful of overflow. Values that will cause overflow are in the following diagram. 53</P> 54<TABLE border="1"> 55 <TBODY> 56 <TR> 57<TH>Function Name</TH> 58<TH>This value or less is OK.</TH> 59<TH>Beyond this value is not allowed.</TH> 60 </TR> 61 <TR> 62<TD><CODE>OS_SecondsToTicks32()</CODE></TD> 63<TD>128 (seconds)</TD> 64<TD>129 (seconds)</TD> 65 </TR> 66 <TR> 67<TD><CODE>OS_MilliSecondsToTicks32()</CODE></TD> 68<TD>128154 (Milliseconds)</TD> 69<TD>128155 (Milliseconds)</TD> 70 </TR> 71 <TR> 72<TD><CODE>OS_MicroSecondsToTicks32()</CODE></TD> 73<TD>128154 (Microseconds)</TD> 74<TD>128155 (Microseconds)</TD> 75 </TR> 76 </TBODY> 77</TABLE> 78<P><BR> Further, values that overflow in 64 bit operation are: 550419050 microseconds (about 6.4 days) for <CODE>OS_MicroSecondsToTicks*()</CODE>, 550419050955 milliseconds (about 7.4 years) for <CODE>OS_MilliSecondsToTicks*()</CODE>, and 550419050955 seconds (about 17,000 years) for <CODE>OS_SecondsToTicks*()</CODE>.</P> 79<H2>See Also</H2> 80<P><CODE><A href="OS_InitTick.html">OS_InitTick</A><BR> <A href="OS_GetTick.html">OS_GetTick</A><BR> <A href="../alarm/OS_SetAlarm.html">OS_SetAlarm</A><BR> <A href="../alarm/OS_SetPeriodicAlarm.html">OS_SetPeriodicAlarm</A><BR> <A href="OS_TicksToSeconds.html">OS_TicksTo*Seconds</A><BR></CODE></P> 81<H2>Revision History</H2> 82<P>2005/10/07 Changed differences between 32-bit and 64-bit operation.<BR> 2005/10/06 Considered and changed overflow for 32-bit and 64-bit operation.<BR> 2004/02/25 Changed Count to Tick.<BR> 2004/02/24 Initial version.</P> 83<hr><p>CONFIDENTIAL</p></body> 84</HTML>