Skip to main content

Customer Login

This content is for Speedgoat customer only. Log in to see content.

Forgot your password?

Don't have a Speedgoat account? Create an account.

Documentation
CONTENTS
https://www.speedgoat.com/help/slrt/page/icon_documentation.jpg

Interrupt Usage Notes

Interrupt Usage Notes — Usage information about the I/O module

Interrupt Generation Example

Let us assume we have an interrupt block with the following parameters:

Parameter Value
Interrupt source"FPGA input pin"
Edge detection 2
Debounce duration vector300e-9
Interrupt delay vector1e-6
Advanced settingsenabled
Threshold vector2
Repetition vector3
Time gap vector0.7e-6

With the above settings in place, the Cos interrupt block detects both the rising and the falling edge of the input signal. For a time period of 300 ns, the input signal is debounced and the "bouncing" edges at the input are ignored (like the second rising edge).

Every event is delayed 1μs in relation to the input signal. With a threshold value of 2, an event is only propagated every third time. The other detected events will be ignored.

The repetition is applied after the threshold operation. In this example, every propagated event is repeated 3 times (1 event + 3 repetitions = 4 interrupts) with a time gap of 0.7 μs in between.

The lowest plot with all the repetitions represents the timing diagram of all the interrupts which trigger the Simulink model.

Flag- and Timestamp Output Examples

When enabled, the Interrupt module block provides additional information to every generated interrupt. First there is a timestamp to each interrupt and secondly there is a flag output which shows how many interrupts got lost.

The timestamp is a 64-bit counter running on the FPGA which starts to count when the model is started. Every time an interrupt triggers the Simulink model, the output is updated with the actual counter value. The green dotted lines show that the value changes at every interrupt. The timestamp units are FPGA ticks.

If the interrupt module is still performing the delay operation, new incoming events will be ignored. The same applies if the module is performing the repetition operation. The flag output value is incremented for every event missed/ignored. The red dotted line illustrates one missed event, during the repetition operation, and the incrementing value of the flag output.

Example Model

The Interrupt Setup block configures the Simulink and Simulink Real-Time software to treat a particular Function-Call Subsystem as an Interrupt Service Routine (ISR).

Refer to the Interrupt Setup block documentation for more information.

[Note]Note

For MATLAB releases prior to R2020b, please refer to the interrupt settings described in the MathWorks web documentation.

In the Function-Call Subsystem, the CoS Interrupt block is used to handle and clear the incoming interrupts. Given that all channels of the CoS Interrupt generate the same interrupt, the Event vector must also be checked. Each element of the Event Vector represents a corresponding channel.

The following model of a Function-Call Subsystem shows one example of how to handle 4 channels. The Selector Block separates one element from the vector and enables an Enabled Subsystem when an interrupt occurs at this specific channel. The Enabled Subsystems include the ISR for their respective channels.

Latency

Depending on the settings of the CoS Interrupt block, bear in mind that the latency of the interrupt can be different. The following table shows the time needed, before the ISR is executed, depending on the enabled Outputs:

Output Time needed
Event 2 x PCI-read access
Timestamp n x 2 x PCI-read access
Flag n x 1 x PCI read access

n: number of channels with an event at the same time

1 x PCI-read access = 1.5 µs

[Note]Note

These times only occur when the corresponding output is enabled.

[Note]Note

The FPGA clock frequency and the corresponding time of a tick can be found in the Setup block.