- Simulink Coder block System Start Function Execution Code
- C2000 Driver blocks initialization
- Simulink Coder block System Start Function Exit Code
- Simulink Coder block System Initialize Function Execution Code
- Initialize Function subsystem (User-Defined Functions)
- Simulink Coder System Initialize Function Exit Code
- Enable interrupts (triggers the scheduler).
TI 28377S & Simulink C2000 Embedded Coder: Initialize/Start-up/Shutdown Procedures
10 views (last 30 days)
Show older comments
Hello,
I have been using Simulink's C2000 Embedded Coder add-on to program a TI 28377S LaunchPad. When programming and powering up the DSP, I found that the ePWMs were briefly going high before going into states defined by the ePWM block (in my case, complementary), which could be problematic if the system is (still) energized. I was looking at some of the examples provided and found the c28035pmsmfoc_cla one, which has custom code blocks (System Initalization). I had a few questions about the custom code blocks and how they interact with Embedded Coder, as the documentation isn't overly specific for this purpose.
- When the model is compiled and converted to code, what is the order of operations that Simulink follows? Does it follow something like this: System Initialize code block -> Module (ADC, PWM, etc.) configuration -> System Start code block -> Main body of code (model)? When do interrupts become enabled?
- For the System Start block, would it be necessary to disable/enable interrupts in the function's body or is it automatically handled by Simulink? Or are they not enabled by this point when starting the DSP?
- For the System Terminate block, does this code execute when the Stop button is pressed in Simulink? Or does it require some other event to execute (i.e. we need to create a subsystem triggered by an interrupt)?
As a whole, is there more significant documentation of these blocks and their functionality when using Embedded Coder? Are there more in-depth examples that show how to use these blocks for configuring modules to perform certain functions (e.g. the initialization of ePWM modules to an off state and an equivalent shutdown procedure via Simulink)?
Thanks a lot for your help.
0 Comments
Accepted Answer
Antonin
on 2 Oct 2017
Hi Michael,
These are good questions that are often coming up.
The first thing to know if that all GPIOs including your ePWM pins are set to GPIO inputs by default. In that mode, the pin is floating, but reads high most of the time you hook a scope probe to it (I don't have an explanation for this). There will be some time before you can take control of the pins where your system will have to accept this state. In the demo you are referring to (c28035pmsmfoc_cla), the motor driver chip DRV8312 is disabled by default. We enable it inside the "FOC Alogrithm" subsystem by setting GPIO pins 1, 3 and 5 to high. Anything that happens prior to this has not effect on the state of the power transistors. More info in the power-up section of the SLES256 document (DRV8312).
There is an internal pull-up register that allows a weak pull-up on pins, but it is disabled by default on all pins on the F28377S (not on all pins for older devices).
Here is the start up sequence, my recommendation is to look for yourself in the generated code:
Therefore, interrupts are disabled during the execution of the System Start block.
The terminate function are called when you press the stop button during "External mode" simulations. There are ways to stop the execution of the model by using rtmSetErrorStatus function in the generated code. Look for this function name in the documentation.
More info in:
I hope it helps,
Antonin.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!