This example shows how to use the C28035 LIN Receive, LIN Transmit, and PWM blocks to generate a pulse waveform.
Texas Instruments™ F28035 controlCARD with docking station
Oscilloscope and probes
Texas Instruments F28035 controlCARD: c28035lintest.slx
This example model runs a single LIN node in loopback mode. The Read Duty Cycle subsystem passes the duty cycle values to the LIN Transmit block. The LIN Transmit block transmits the values to the LIN Receive block, which sends them to the ePWM Output block. The Verify Data block compares the original duty cycle values with the values from the LIN Receive block. If the values do not match, the Data Non-Match LD3 block flashes the LD3 LED on the C28035 controlCARD. In addition, a LIN_STAT signal is attached to the Status output from the LIN Receive block. To know the LIN communication status, you can check the LIN_STAT variable in the generated code running in Texas Instruments Code Composer Studio™.
The duty cycle of the generated pulse waveform is determined by the relative ratio of the received pulse width value and the pulse period, which is fixed at 64,000 clock cycles. The duty cycle toggles between 25%, 50%, and 75% based on the selection.
PWM duty cycle can be changed by double-clicking the Read Duty Cycle subsystem and selecting either 25%, 50%, or 75% value from the window that opens up.
Connect the output of PWM1 on the board to the analog input of the oscilloscope.
The LIN module is set to work in loopback mode. No external LIN hardware is needed because the LIN TX/RX signals are emulated in the software.
Browse to Configuration Parameters > Hardware Implementation > Target hardware resources.
Set LIN mode to Master in LIN page.
Select Enable loopback on the LIN page.
Set ID slave task byte to a value between 0x00 and 0xFF.
For the LIN Transmit and LIN Receive blocks:
Use the same ID Mask as input for both LIN TX ID Mask and RX ID Mask.
Use LIN ID to make (
LIN ID XOR
ID Mask) ==
ID-Slave Task Byte.
For information about how to setup the LIN peripheral, see Configuring LIN Communications.
Open the model, double-click the Duty Cycle block, and select a new duty cycle value.
In the Configuration Parameters window, click Hardware Implementation and go to Target hardware resources > External mode and set the Serial port parameter to the COM port at Device Manager > Ports (COM & LTP) in Windows. For more information, see
Go to Hardware tab and click Monitor & Tune.
Use the diagnostic viewer to follow the build progress, and wait until the code loads and runs on the target hardware.
Observe the change of the PWM waveform on the oscilloscope.
Change the duty cycle while in External mode and observe the changes in the PWM waveform on the oscilloscope.