# OS_SetPeriodicVAlarm

## Syntax

      #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 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

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

CONFIDENTIAL