LIN-Based Control of PWM Duty Cycle

This example shows how to use the C28035 LIN Receive, LIN Transmit, and PWM blocks to generate a pulse waveform.

Required Hardware:

Available versions of this example:

Contents

Model

The following figure shows the example model.

Description

This example model runs a single LIN node in loopback mode. The "Read Duty Cycle" subsystem passes the duty cycle values set by the user to the "LIN Transmit" block. The "LIN Transmit" block transmits the values to the "LIN Receive" block, which sends them on 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. You can check the LIN communication status by looking at the "LIN_STAT" variable from the generated code running in TI CCS.

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 64000 clock cycles. The duty cycle toggles between 25%, 50%, and 75% based on user selection.

PWM Duty Cycle can be changed by double clicking "Read Duty Cycle" subsystem and selecting either 25%, 50%, or 75% value from the GUI that opens up.

Note that "Generate Waveform for Simulation" and "Display PWM Waveform" are dedicated to simulation only. Use these blocks to simulate and observe effects achieved with the generated code.

Hardware Connections

Connect the output of PWM1 on the board to the analog input of the oscilloscope.

Note that LIN module is set to work in "loopback" mode. No external LIN hardware is needed as the LIN TX/RX signals are emulated in software.

How to Setup LIN Loopback Mode

For "LIN Transmit" and "LIN Receive" blocks:

For details about how to setup LIN peripheral, please refer to Configuring LIN Communications.

How to Run the Example in the Simulation

How to Run the Example on the Board