Configuring Timers in Simulink Embedded Coder Support Package for Texas Instruments C2000 Processors

8 views (last 30 days)
Hello,
I am using TMS320F28379D (in OP8666 by OPAL RT) and Code Composer Studio (CCS) and I run Simulink models in real time. I want to use the available Embedded Coder Support Package for Texas Instruments C2000 Processors that is integrated in Simulink, to use the Timers of the processor (for example to configure the Timers as in the interrupt_ex3_sw_prioritization code that I found in the C2000Ware_4_XX_XX_XX\driverlib\f2837xd\examples\cpu1\interrupt). I am not sure which block I should use in Simulink to configure the period (PRD register) of the Timers (TIM0, TIM1, TIM2 registers) and use them to generate the hardware interrupts at the time intervals that I want. Maybe the Software Interrupt or the C28x Hardware Interrupt in combination?. Any advice on this will be very helpful!
Thank you in advance

Answers (1)

Ganesh Thambhahalli Satyen
Hi Nena,
I understand that you want to configure the Timers present on the board to generate hardware interrupts at the desired time intervals.
The following MATLAB Answer gives insights onto how to configure General Purpose Timers on the same F28379D:
More details about the Asynchronous Scheduling example referenced in the above answer can be found in the following MathWorks documentation link:
I hope the above information helps resolve your query.
  1 Comment
Nena
Nena on 14 Sep 2023
Hi Ganesh,
Thank you for sharing the link (https://in.mathworks.com/help/ti-c2000/ug/asynchronous-scheduling.html), I have checked the example, but I am not sure that this is the case of my application, because the frequency of the signals/pulses that I want to generate is not a fixed one, as when generating PWM pulses with ePWM block, but the frequency of these signals depends on the control logic of the model that I create in the Simulink and I want this to be random and change. Also, in the above provided example, I run the model, and while the PWM3 and PWM4 work, the PWM5 does not seem to work, so I cannot figure out how this example works.
Regarding this link (https://in.mathworks.com/matlabcentral/answers/413860-how-to-configure-general-purpose-timer-on-f28379d-ti-c2000), Trip Zone unit in ePWM can be used to drive the output high/low based on the external event, but I am not using PWM outputs, but GPOs, so I cannot use the PWM to the same pin out!
I am actually trying to use software-based interrupt mechanism in my models (via using the Software Interrupt block in Simulink) to produce General Purpose output signals with a predefined latency of 1 microsec for my DELFINO Board. If I wanted to do this with ePWM, I would just use the dead time zone inside this block.
From my previous experience with microcontroller boards (using c programming, not Simulink Coder), I used to use the DSP available timers (just like T0-T2 of the DELFINO) to generate this predefined latency before generating the actual signals to the General Purpose outputs, via asserting a timer interrupt for the specific time-interval (e.g., 1 microsec). This way, when I use the timer interrupt services, when the DSP detects the interrupt request it forces the program to jump into the interrupt function loop, after the time that I have programmed the timer to do so. Then, inside the timer interrupt function, I control the output signals, and clear the interrupts flag.
So, to sum up:
  1. I have not found any example that shows how to configure the Software Interrupt block in combination with the Hardware Interrupt block. Is there an example available?
  2. The algorithm that I want to implement using the C2000 support package:
% Timerx configuration, (x=0, 1, 2)
Enable Timerx interrupt;
Clear Timerx interrupt flag;
Set Timerx period % max 65535
if (COMMAND==1) % when I receive a logic high signal
{activate Timerx;} % the counter is activated
else {Set GPDO to Low}
Timerx Interrupt Service Routine % the Timerx Interrupt Service Routine is called after the Timerx period that I have set has been completed
{ Set GPDO to High; % Logic high is set to the DSP output pin
deactivate Timerx; % the timer is deactivated
clear Timerx interrupt flag;
}
Do you believe that I should use the control law accelerator (CLA) blocks to implement this operation?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!