How add interrupt function to c file

5 views (last 30 days)
During creating Device Drivers for the Embedded Target for Motorola HC12,I want to add interrupt function to c file by TLC file.In TLC file,I don't want to use "Start" function or "Outputs" function.I want that the interrupt function independents of void task_step() and void task_initialize(). How to achieve it? thank you .

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 21 Nov 2011
I don't know what the "proper" way to do this is, but here's a quick-and-dirty way that I can think of:
%openfile tmpBuf
void interruptFunction()
{
/* do something here */
}
%closefile tmpBuf
%assign modelSrc = LibGetModelDotCFile()
%<LibSetSourceFileSection(modelSrc,"Functions",tmpBuf)>
You can also add a declaration to model.h if you like:
%openfile tmpBuf
void interruptFunction();
%closefile tmpBuf
%assign modelH = LibGetModelDotHFile()
%<LibSetSourceFileSection(modelH,"FcnPrototypes",tmpBuf)>
You should be able to use this in any part of your TLC file (since you are reaching into specific portions of the generated code), I don't think it should matter whether you call it from Start or Output or any other method.
I haven't tried this out, so please post back if you run into issues with this solution. Typically this type of thing can be done in the custom file processing template, but my guess is that you can do it from an S-function TLC as well.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!