# null

# on frStartCycle

[CAPL Functions](../../CAPLfunctions.md) » [FlexRay](../CAPLfunctionsFlexrayOverview.md) » on frStartCycle

**Valid for**: CANoe DE • CANoe4SW DE

## Function Syntax

* `on frStartCycle *`

  This procedure is always called if one of the cycle definitions below does **not** apply. This means that for a certain cycle either this function or one of the two functions below is called.

* `on frStartCycle <cycle>`

  This function is only called for a certain cycle `<cycle>`. This procedure must not describe any cycle that has already been described by a procedure of the form "on frStartCycle (`<base cycle>`, `<cycle repetition>`)".

* `on frStartCycle (<base cycle>, <cycle repetition>)`

  This function is called for all cycles that comply with the defined cycle multiplexing (`FR_Cycle modulo <cycle repetition> = <base cycle>`). This procedure must not describe any cycle that has already been described by a procedure of the form "on frStartCycle `<cycle>`".

## Description

This event procedure can be generated by FlexRay at the beginning of each communication cycle and contains the NM vector valid for this cycle.

An optional channel parameter for event filtering can be assigned to all functions.

**Example**: In the example, the event procedure is only called for the 16 cycles of FlexRay channel 2.

```
on frStartCycle MsgChannel2.16
```

## Parameters

* `*`: Specifies the default procedure. This procedure is called on every cycle start for which no explicit event procedure exists.
* `<cycle>`: This number describes a certain cycle. The value range is 0...63.
* `<base cycle>`: This number describes the base cycle. The value has to be less than the repetition factor; the value range is 0...63. Together with the repetition factor this value determines the "Cycle Multiplexing".
* `<cycle repetition>`: This number describes the cycle repetition factor. The value has to be between 1 and 64 and has to be a power of 2 (1, 2, 4, 8, 16, 32 or 64). Together with the base cycle this value determines the "Cycle Multiplexing".

## Selectors

* **Time (data type dword)** / **Time\_ns (data type int64)**: The StartCycle event time stamp that has been synchronized with the global time base in the computer (CAN hardware or computer system clock). Timer unit: 10 microseconds. NS timer unit: nanoseconds. **Write-protected!**

* **MsgChannel**: Channel in the tool that the FlexRay CC determines. **Write-protected!**

* **FR\_Cycle**: Cycle number of the FlexRay cycle beginning herewith. **Write-protected!**

* **FR\_nmLength**: Length of the presented Network Management Vector in bytes. **Write-protected!**

* **FR\_nmVector**: Network Management Vector of the message. The number of valid data bytes is specified by the `nmLength`. Direct access to the data is not possible. **Write-protected!**

* **FR\_correctionOffset**: Provides the signed correction value for the synchronization offset of the previous cycle. Permitted maximum value from the FlexRay parameters: `pOffsetCorrectionOut`. Unit: Microticks. **Write-protected!**

* **FR\_correctionRate**: Provides the signed correction value for the synchronization rate of the previous cycle. Permitted maximum value from the FlexRay parameters: `pRateCorrectionOut`. Unit: Microticks. **Write-protected!**

* **FR\_correctionFailedCounter**: Indicates the number of continuous previous cycles in which synchronization was not possible. **Write-protected!**

* **FR\_passiveToActiveCounter**: If the CC is in passive mode, this counter will indicate the number of continuous previous cycles in which clock synchronization was possible. **Write-protected!**

## Example

The following program reacts on every start of a cycle and prints info in the Write Window.

```c
variables
{
    const int cWriteTextSize = 512;
    char writeTxt[cWriteTextSize];
}
void myprint(char text[])
{
    write("%s", text);
}
float getTime (float time)
{
    // convert NS to SEC:
    return time / 1000000000.0;
}
on frStartCycle *
{
    snprintf(writeTxt, cWriteTextSize, "%10.6f: SOC %2d on FR%d!", getTime(messageTimeNS(this)), this.FR_Cycle, this.MsgChannel);
    myprint(writeTxt);
    output(this); // only required in Measurement Setup
}
```
