TimerOut
 
Component TimerOut
Flip-flop output 1:1
Component Level: High
Typical Usage:
(Examples of a typical usage of the component in user code. For more information please see the page Component Code Typical Usage.)

Required component name is "TO1".
There are the following three typical usage modes:

(1)
The easiest usage of the component is a simple output signal generator. There is not method required in this simple mode. The component initializes the timer, which produces the output signal with 50% duty.

Note: In this case it is recommended to turn off all the methods of the component.

(2)
The component may be at the same time used as a simple periodic event generator - event OnRising or OnFalling may be used. Usually it's recommended to use only one of these events.

 EVENTS.C

int event_cntr = 0;

void TO1_OnFalling()
{
  ++event_cntr; /* increment event counter */
}

(3)
Advanced methods of the component allows to change period of the event in runtime. It is possible to select a period from the predefined list using SetPeriodMode method or to set a value from the interval using SetPeriod and SetFreq methods (please refer to Timing dialog box).
In the following example the output signal period is switched after each 255-th invocation of the event handler. The period mode is changed sequentially from three predefined values.

 EVENTS.C

int rpt_cntr = 255, mode = 0;

void TO1_OnFalling(void)
{

  if( --rpt_cntr==0 ) {  // If the event was generated 255times
    if( ++mode==3 ) mode = 0; // Select next mode of the period
    TO1_SetPeriodMode( mode ); // Set new period mode
    rpt_cntr = 255; // Set repeat counter
  }
}

(4)
Component initial level of the output signal may be changed using methods SetValue and ClrValue. These methods may used only if the component is disabled.

 MAIN.C

void main(void)
{
  /* output signal synchronization */
  TO1_Disable();  /* disable the component */
  TO1_ClrValue(); /* set output level to LOW */
  TO1_Enable();   /* enable the component */
}