This example shows how to use the Texas Instruments™ C28x™ peripherals and Hardware Interrupt blocks to control the real-time execution of Simulink® function-call subsystems in an asynchronous fashion.
Spectrum Digital F2808/F2812/F28335 eZdsp or Texas Instruments LaunchPad/controlSTICK/controlCARD with docking station
Oscilloscope and probes
These are the Simulink models available for different C2000 processors:
F281x-based board: c281x_asyncscheduling_ert.slx
F280x/F2823x/F2833x-based board: c280x_2833x_asyncscheduling_ert.slx
Piccolo F2803x/F2806x-based board: c280xx_asyncscheduling_ert.slx
Concerto F28M35x/F28M36x- based board: c28M3xx_asyncscheduling_ert.slx
Piccolo F2807x/F28004x or Delfino F2837xS/F2837xD-based board: c2807x_2837xx_asyncscheduling_ert.slx
Note: To use the F28M35x/F28M36x controlCARD, you need Embedded Coder® Support Package for Texas Instruments C2000™ F28M3x Concerto™ Processors.
The EV Timer or ePWM blocks are used to configure the timer interrupts. The timer interrupts are triggered based on the timer period, and the eCAN message receive interrupt is triggered when a message is received. The Hardware Interrupt block triggers the interrupt service routines (ISR) for the timer interrupts as well as for the eCAN message receive interrupt. The ISRs in turn call the function-call subsystems connected to the Hardware Interrupt block output ports.
The outputs of the first two subsystems are free-running counters. The sum of the counters is used to control the duty cycle of PWMB for F2812 or ePWM2 for F2808/F28335. The PWM waveform duty cycle increases linearly from 0 to 100%. The third subsystem contains an eCAN Receive block whose message output controls the duty cycle of the PWM block (PWMA for F2812 or ePWM1 for F2808/F28335). The duty cycle varies from 0 to 100% because the eCAN messages are received from the eCAN Transmit block.
Note: The Self-Test mode of eCAN_A is enabled to connect the eCAN_A transmitter and receiver internally to avoid external connection between the transmitter and the receiver. For disabling the Self-Test mode of eCAN_A, the transmitter and the receiver must be connected together externally.
Run the Model on the Board
To configure, build, and deploy the application that corresponds to your Simulink model:
Modeling a Fault-Tolerant Fuel Control System (Simulink) example on the STM32F746G Discovery board.
Open the model corresponding to your target hardware. Each model is configured for a default target hardware. To select a different target hardware, browse to Configuration Parameters > Hardware Implementation > Hardware board.
Go to Target hardware resources > eCAN_A, select Self-Test Mode, and click OK.
On the Hardware tab, Click Build, Deploy & Start > Build Stand-Alone to generate, build, load, and run the program.
Observe the changes of the PWM waveform on the oscilloscope.