# OS_*SecondsToTicks*

## Syntax

      #include <nitro/os.h>

      #define OS_MicroSecondsToTicks( microSec )
      #define OS_MicroSecondsToTicks32( microSec )

      #define OS_MilliSecondsToTicks( milliSec )
      #define OS_MilliSecondsToTicks32( milliSec )

      #define OS_SecondsToTicks( sec )
      #define OS_SecondsToTicks32( sec )

      (These are all macros.)

## Arguments

sec | Seconds
milliSec | Milliseconds
microSec | Microseconds

## Return Values

The tick value that corresponds to the time specified by the argument.

## Description

This function obtains the tick value that corresponds to the time specified by the arguments.

One tick unit is 1/64 of the system clock.

`OS_MicroSecondsTo Ticks*()` converts microseconds to tick values.
`OS_MilliSecondsToTicks*()` converts milliseconds to a tick value.
`OS_SecondsToTicks*()` converts seconds to a tick value.
These functions are all defined as macros.

Functions with `32` in their names conduct 32-bit internal calculations. Those without `32` 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 `32` 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.

When operating in 32-bit mode, be careful of overflow. Values that will cause overflow are in the following diagram.

Function Name | This value or less is OK. | Beyond this value is not allowed.
--- | --- | ---
`OS_SecondsToTicks32()` | 128 (seconds) | 129 (seconds)
`OS_MilliSecondsToTicks32()` | 128154 (Milliseconds) | 128155 (Milliseconds)
`OS_MicroSecondsToTicks32()` | 128154 (Microseconds) | 128155 (Microseconds)

Further, values that overflow in 64 bit operation are: 550419050 microseconds (about 6.4 days) for `OS_MicroSecondsToTicks*()`, 550419050955 milliseconds (about 7.4 years) for `OS_MilliSecondsToTicks*()`, and 550419050955 seconds (about 17,000 years) for `OS_SecondsToTicks*()`.

## See Also

`OS_InitTick
OS_GetTick
OS_SetAlarm
OS_SetPeriodicAlarm
OS_TicksTo*Seconds
`

## Revision History

2005/10/07 Changed differences between 32-bit and 64-bit operation.
2005/10/06 Considered and changed overflow for 32-bit and 64-bit operation.
2004/02/25 Changed Count to Tick.
2004/02/24 Initial version.

CONFIDENTIAL