CAN Calibration Protocol and External Mode
This example shows how to use the CAN Calibration Protocol (CCP) block to monitor model signals and tune parameter values in the application code running on the target hardware. You can use either External mode or a third-party calibration tool to interact with the application. The parameters can be loaded in the hardware flash memory and copied to RAM during initialization.
- Vector-Informatik CAN hardware and drivers must be installed on your host computer, and the baud rate set 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.
Available versions of this example:
- The example model c28x_ccp_ert.slx can be used for TI Piccolo F2803x/F2806x, F28x3x, F280x, F281x target hardware. Default F28335 target hardware is selected.
- To change the target hardware open Model Configuration Parameters and go to Hardware Implementation > Hardware board.
The following figure shows the example model.
This example shows how to use the c28x CCP block. During code generation, 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 the signals and update the parameters on the real-time application generated for the model.
How to Run the Example
The following sections explain how to configure, build, and deploy the application for your Simulink® model.
- While opening the model c28x_ccp_ert.slx, 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 Model Configuration parameters and select the Hardware Implementation pane. Select the 'Hardware board' to match your requirements.
- Ensure that the 'Communication interface' is selected as CAN. The 'Communication interface' can be accessed at Model Configuration Parameters > Hardware Implementation > Target Hardware Resources > External Mode > Communication interface.
- Go to the Code Generation pane and select the 'Toolchain' to match your requirements.
- Press the Play Button to run the model in External mode.
- Use the diagnostic viewer to follow the build progress, and wait until the code is loaded and runs in the target hardware.
- You can now view logged data in the scope windows.
Note: CCSv3.3 Toolchain is supported in the c28x_cpp example.
Signal Logging and Parameter Tuning with External Mode
The model c28x_ccp_ert.slx contains a variety of signals and parameters that can be logged or changed while the application is executing in real-time on target hardware. 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.
STEP_PARAM takes advantage of a custom storage class package labeled tic2000demospkg to load parameters in flash memory and run them from RAM for calibration using the ramfuncs section available in the memory map.
For this example, a custom storage class package labeled tic2000demospkg has been created. Run cscdesigner -advanced tic2000demospkg to view the definition of the tic2000demospkg package.
This example is compatible with both standalone execution from flash memory and execution from RAM. In both cases, STEP_PARAM will be stored in the ramfuncs section. 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.
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).