High-performance Counter Sample [Counter]


Appearance


Overview

This is a sample that uses the counter function for devices equipped with the high-performance counter.

When viewing/changing the source code for basic counter functions only, please refer to [Flow Chart for Counter Function].
When viewing/changing the source code for the count match function in addition to the counter function, please refer to [Flow Chart for Output Pulse when Count Match [High-performance Counter]].
When viewing/changing the source code for the control input signal function in addition to the counter function, please refer to [Flow Chart for Control Input Signal [High-performance Counter]].

This sample program requires use with a high-performance counter type device.
To check the counter type of the device you are using, please refer to [Counter Type Specifications].

If you are using a usual counter type device, please use the [Usual Counter Sample].

This sample program uses message notifications for event processing.
If you want to use callback functions, please use the [High-performance Counter Callback Sample].



Step to Operate

  1. Input the device name set in the Device Manager into [Device Name], and click the [CntInit] button.

  2. Click the [Counter Mode...] button to display the [Counter Mode Setting] dialog.
    After setting the counter mode, click the [OK] button.

    For details about counter mode settings, please refer to Counter Operation Mode Setting.

  1. Click the [Notification...] button to display the [Notification Setting] dialog.
    In the case of using count match function, configure the notification settings, and click the [OK] button.
    In the case of not using count match function, click the [Cancel] button to close the dialog.

    For details about count match function, please refer to Count Match Setting [High-performance Counter].
    The operation when the count matches Reg0 or Reg1 is specified in the [Hardware Event Setting] dialog.

    In this sample program, message notification is used for count match notification, error notification, and carry/borrow notification.

  1. Click the [Event...] button to display the [Hardware Event Setting] dialog.
    In the case of using hardware event function, set the hardware event, and click the [OK] button.
    In the case of not using hardware event function, click the [Cancel] button to close the dialog.

    For details about hardware event function, please refer to Hardware Event Setting [High-performance Counter].

    If [General Input] is selected as the event signal input type, do not specify RF0 and RF1.
    If other types are selected, specify either [Rise/Fall/None] in the RF0 or RF1 item.

    If [General Output] is selected as the event signal output type, you can test output a signal from the device.
    Specify the desired channel number and the data to be output, then click the [Signal Output] button.

  1. Click the [CntStart] button to start count.

  2. Click the [CntPreset] button to set the count value to [Channel number × 100].

  3. Click the [CntReset] to clear the count value to 0.

  4. Click the [CntStop] button to stop count.

  5. Click the [CntExit] button to end the use of the device.

  6. Click the [Exit] button to end the program.