CAN Calibration Protocol and External Mode
This example shows how to use the CAN Calibration Protocol (CCP) block. CCP allows you to monitor signals and tune parameter values in the application code running on the target. Use either external mode or a third party calibration tool to interact with the real-time application running on the target processor. Parameters can be loaded in Flash and copied to RAM during initialization for tuning.
Required hardware:
- Before running the model in external mode, install Vector-Informatik CAN hardware and drivers on your host computer, and set the baud rate to 1M to match processor CAN configurations.
- Spectrum Digital F2812/F2808/F28335 eZdsp board, or F2808/F28035/F28044/F28069/F28335 ControlCARD with Peripheral Explorer kit.
- The model runs in MATLAB Win32 as Vector-Informatik supports Win32.
Available versions of this example:
- The example model c28x_ccp.mdl can be used for TI Piccolo F2803x/F2806x, F28x3x, F280x, F281x processors series. Default F28335 processor is selected.
- Open the Model Configuration Parameters dialog and select "Coder Target" under "Code Generation". Next, click "Target Hardware Resources" dialog to select a different processor.
Contents
- Model
- Scope Snapshots
- Description
- How to Run the Example
- With Code Composer Studio v3.3 (CCSv3.3) - Default
- With Code Composer Studio v4 (CCSv4)
- With Code Composer Studio v5 (CCSv5)
- Signal Logging and Parameter Tuning with External Mode
- Signal Logging and Parameter Tuning with a Third Party Calibration Tool
Model
The following figure shows the example model.
Scope Snapshots
Description
This example shows how to use the c28x CCP block. During code generation for this model, an ASAP2 file is generated. The ASAP2 file contains symbol and memory address information. Either external mode or a third party calibration tool can use the generated ASAP2 file to log signals and update parameters on the real-time application.
How to Run the Example
The following sections explain how to configure, build, and deploy the executable.
With Code Composer Studio v3.3 (CCSv3.3) - Default
- While opening the model c28x_ccp.mdl, a script will be processed as a Pre-Load Function callback. This call can be viewed by selecting File > Model Properties > Callbacks > PreLoadFcn.
- The c2000_ccp_data.m callback is setting Simulink® signals and parameters to resolve Simulink objects needed for CCP DAQ lists and Simulink tunable parameters as described in the CCP documentation. This step is required to interact with these signals in real-time using CCP.
- The example model is configured for default processor F28335. Open the Model Configuration Parameters dialog and select "Coder Target" under "Code Generation". Next, click "Target Hardware Resources" dialog to select a different processor.
- Build the model. You can press Ctrl+B or click Build Model button on the toolbar of your model.
- Follow the progress of the build in the MATLAB® command window, and wait until the project is created and built in Code Composer Studio™.
With Code Composer Studio v4 (CCSv4)
CCSv4 support is provided via a makefile based approach. This requires running xmakefilesetup to set the environment. You can ignore the following if you have already gone through these steps. For more information, please refer to the Xmakefile Documentation
- Run XMakefile User Configuration.
- Set the Template parameter to gmake.
- Uncheck the Display operational configuration only checkbox.
- Set the Configuration parameter to ticcs_c2000_ccsv4, click Apply, if you haven't used this tool before, a dialog will ask you to browse to your CCSv4 installation folder. Pick the right folder and click OK.
- Click on the Tool Directories and make sure that the paths are pointing to directories matching your installation. For example:
- C:\Program Files\Texas Instruments\ccsv4\ for CCS Installation
- C:\Program Files\Texas Instruments\ccsv4\tools\compiler\C2000\ for Code Generation Tools
- C:\Program Files\Texas Instruments\bios_5_41_10_36\ for DSP/BIOS Installation
Code Generation and Creation of an .out file using CCSv4:
- While opening the model c28x_ccp.mdl, a script will be processed as a Pre-Load Function callback. This call can be viewed by selecting File > Model Properties > Callbacks > PreLoadFcn.
- The c2000_ccp_data.m callback is setting Simulink® signals and parameters to resolve Simulink objects needed for CCP DAQ lists and Simulink tunable parameters as described in the CCP documentation. This step is required to interact with these signals in real-time using CCP.
- Open the Model Configuration Parameters dialog and select "Coder Target" under "Code Generation". Next, click "Target Hardware Resources" dialog and set the IDE/Tool chain parameter to Texas Instruments Code Composer Studio v4 (makefile generation only).
- Change the selected board and processor to match your hardware.
- Click OK to save the changes.
- Build the model. You can press Ctrl+B or click Build Model button on the toolbar of your model.
- Open CCSv4 and Connect to the Hardware. Load the program on to the hardware using CCSv4 and run.
With Code Composer Studio v5 (CCSv5)
CCSv5 support is provided via a makefile based approach. This requires running xmakefilesetup to set the environment. You can ignore the following if you have already gone through these steps. For more information, please refer to the Xmakefile Documentation
- Run XMakefile User Configuration.
- Set the Template parameter to gmake.
- Uncheck the Display operational configuration only checkbox.
- Set the Configuration parameter to ticcs_c2000_ccsv5, click Apply, if you haven't used this tool before, a dialog will ask you to browse to your CCSv5 installation folder. Pick the right folder and click OK.
- Click on the Tool Directories and make sure that the paths are pointing to directories matching your installation. For example:
- C:\ti\ccsv5\ to set CCS Installation
- C:\ti\ccsv5\tools\compiler\c2000\ to set Code Generation Tools
- C:\ti\bios_5_41_11_38\ to set DSP/BIOS Installation
Code Generation and Creation of an .out file using CCSv5
- While opening the model c28x_ccp.mdl, a script will be processed as a Pre-Load Function callback. This call can be viewed by selecting File > Model Properties > Callbacks > PreLoadFcn.
- The c2000_ccp_data.m callback is setting Simulink® signals and parameters to resolve Simulink objects needed for CCP DAQ lists and Simulink tunable parameters as described in the CCP documentation. This step is required to interact with these signals in real-time using CCP.
- Open the Model Configuration Parameters dialog and select "Coder Target" under "Code Generation". Next, click "Target Hardware Resources" dialog and set the IDE/Tool chain parameter to Texas Instruments Code Composer Studio v5 (makefile generation only).
- Change the selected board and processor to match your hardware.
- Click OK to save the changes.
- Build the model. You can press Ctrl+B or click Build Model button on the toolbar of your model.
- Open CCSv5 and Connect to the Hardware. Load the program on to the hardware using CCSv5 and run.
Signal Logging and Parameter Tuning with External Mode
The model c28x_ccp.mdl contains a variety of signals and parameters that can be logged or changed while the application is executing in real-time. Parameter tuning and signal logging are enabled by the CCP block included in the model. Additionally, when the model is built, it must be configured to generate an ASAP2 file. The ASAP2 file contains information about the signals and parameters that are available for logging or tuning in the real-time application.
The model contains a simple counter with parameterized step size, STEP_PARAM.
For this example, a custom storage class package labelled tic2000demospkg has been created.
STEP_PARAM takes advantage of a custom storage class package labelled tic2000demospkg to load parameters in Flash and run them from RAM for calibration using the ramfuncs section available in the memory map. Run cscdesigner -advanced tic2000demospkg to view the definition of the tic2000demospkg package.
This example is compatible with both standalone execution from flash and RAM execution. In both the cases, STEP_PARAM will be stored in the ramfuncs section available in the memory map. You can update the parameter STEP_PARAM and log the output of the counter, COUNTER_SIGNAL. Additional signals available for logging are SINE_SIGNAL, PULSE_SIGNAL, and the RANDOMx signals.
Before running the model in external mode, you must have Vector-Informatik CAN hardware installed on your host computer.
To run the model c28x_ccp.mdl in external mode:
- Ensure the model is already built and running on the target.
- Double-click the convenience block Switch External Mode Configuration, select the external mode option and click OK.
- Run the model in external mode by selecting Simulation > Connect To Target.
- You can now view logged data in the scope windows.
- To change the parameter STEP_PARAM in the real-time application: first change its value, "STEP_PARAM.Value", in the MATLAB workspace; then update the model to apply this new value to the real-time application; to update the model select Simulation > Update Diagram or press Ctrl+D.
Signal Logging and Parameter Tuning with a Third Party Calibration Tool
As an alternative to the external mode, you can use a third party calibration tool for signal logging and parameter tuning. The same signals and parameters that are available with external mode may be logged or updated using third party calibration tool. While using a third party calibration tool. Make sure that your tool is set in compliance with the word addressable nature of TI C2000 processors (16-bit addressable).