# OS_SetPeriodicVAlarm

## C Specification

      #include <nitro/os.h>

      void OS_SetPeriodicVAlarm(
      OSVAlarm*           alarm ,
      s16                 count ,
      s16              delay ,
      OSVAlarmHandler     handler ,
      void*            arg );

## Arguments

alarm | Pointer to the V count alarm structure for setting V count alarm
count | The V Count at which the V Count alarm will be actuated (handler will be called) in each frame
delay | The maximum permissible number of V Counts for delay
handler | The V count alarm handler
arg | The argument used when the V Count alarm handler is called

## Return Values

None.

## Description

Sets a periodic V Count alarm.

In each frame, `handler` is called when the V Count reaches `count`. The V count alarm handler `handler` is an `OSVAlarmHandler` function type defined by the following:

`typedef void (*OSVAlarmHandler)( void* );`

handler is called from the OS V-count interrupt handler. Therefore, interrupts are prohibited. When the `handler` is called, it takes `arg` as an argument.

It is possible to specify the amount of permissible delay when the hander cannot be called at the exact number of specified V Count because of another V count alarm or interrupt. For example, at count=100 and delay=5, V count is called if it is possible to call it by count 105, even if it was not possible to call it by count 100. When you specify `0`, the alarm is called only at the specified V count. If `OS_VALARM_DELAY_MAX`, it is always called when a call is possible for the specified V count and subsequent V counts. For details, see the description in VAlarm Overview.

If `alarm` is specified for the pointer to the `OSAlarm` structure in which the V count has been set, it stops with `OS_Panic()`.

`OS_CancelVAlarm()` or `OS_CancelVAlarms()` is used to stop the V Count alarm.

## See Also

`OS_InitVAlarm`, `OS_CreateVAlarm`, `OS_SetVAlarm`, `OS_CancelVAlarm`, `OS_CancelVAlarms`

## Revision History

03/08/2005 Standardized the use of the term 'interrupt' in Japanese.
08/30/2004 Added statement about not being able to use the set V alarm structure.
07/06/2004 Added statement about delay.
02/24/2004 Initial version