How add interrupt function to c file

1 次查看(过去 30 天)
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 .

采纳的回答

Kaustubha Govind
Kaustubha Govind 2011-11-21
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by