User`s guide

5 Interrupt Support
Function Description
Start
Runs as the last item when starting a model, just
before the model runs. It is typically used to turn
on interrupt generation. Program this function to
enable interrupts on the board and start any action.
Stop
Runs at the beginning of a stop request, before any
mdlTerminate entries for any block in the model
runs. It is typically used to turn off interrupt
generation. Program this function to disable
interrupts from the board and stop any action. This
is the first action called, when a target application
stops executing.
Note You mu
st use the
Stop function to turn off interrupts if you have turned
them on in t
he
Start function. In this way, the stop and start functions
should ca
ncel each other.
To add int
errupts for your custom driver, use the following general steps:
1 Create a
hook file in the following directory:
matlabroot\toolbox\rtw\targets\xpc\target\build\
xpcblocks\thirdpartydrivers
Hook fi
les are C files (
.c). For ex ample, look at files i n
matla
broot\toolbox\rtw\targets\xpc\target\build\src
,suchas
xpc68
04hooks.c
.
2 Name the hook file something like:
your_company_name_board_hook.c
3 As necessary, create the interrupt functions the PreHook, PostHook, Start,
and
Stop functions and add them to the hook file. See “Guidelines for
Creating Interrupt Functions” on page 5-9 for information on how to create
these functions.
5-8