1.13 FLEXCOM LIN
This example application shows how to use the FLEXCOM module in LIN mode.
Description
In this example, the LIN host reads the state of the LED and the switch from the LIN client device every second by sending a LIN receive command. The LIN client responds with a data byte containing the state of the switch (Bit[0]) and the state of the LED (Bit[1]).
Upon receiving the response, the LIN host evaluates whether the switch LIN client is pressed or released. If the switch LIN client is released, the LIN host toggles the state of the received LED and instructs the LIN client to set the LED to the new state (turn off the LED if it was previously on, and vice versa) by sending a LIN transmit command.
If the switch LIN client is pressed, the LIN host turns on its own LED and does not instruct the LIN client to change the state of its LED.
LIN is only available for FLEXCOM 0 to 5.
Downloading and Building the Application
To clone or download this application from Github, go to the main page of this repository and then click Clone button to clone this repository or download as zip file. This content can also be downloaded using content manager by following these instructions.
Path of the application within the repository is apps/flexcom/flexcom_lin/master/firmware and apps/flexcom/flexcom_lin/slave/firmware.
To build the application, refer to the following table and open the project using its IDE.
| Project Name | Description |
|---|---|
| sam_9x60_curiosity.X | MPLABX project for SAM9X60 Curiosity Development Board |
Setting Up AT91Bootstrap Loader
To load the application binary onto the target device, we need to use at91bootstrap loader. Refer to the at91bootstrap loader documentation for details on how to configure, build and run bootstrap loader project and use it to bootstrap the application binaries.
Setting Up the Hardware
The following table shows the target hardware for the application projects.
| Project Name | Description |
|---|---|
| sam_9x60_curiosity.X | SAM9X60 Curiosity Development Board |
Setting Up SAM9X60 Curiosity Development Board
- connect www.mikroe.com/lin-click into mikroBUS 1 socket using wires
- Connect the Debug USB port on the board to the computer using a micro USB cable
- Connect a programming cable from JTAG connector J12 on board to programmer(J-32 Debugger)
- Connect programmer(J-32 Debugger) to computer using a micro USB cable
- Connect the USB port J1 on board to the computer using a micro USB cable (to power the board)
- The hardware setup requires two boards, one acting as the LIN Host and the other as the LIN Client
- Connect the LIN Click
board to the mikroBUS socket on the board using wires, following the
table below
mikroBUS LIN Click 9x60 Curiosity GND GND - CS LIN_EN PA8 - TXD PA21 - RXD PA22 +3.3V +3.3V - +5V +5V For host only - The host node should be enabled by the proper configuration of the MODE resistor on the click board
- Connect a wire from VS on the LIN Host click board to 5V
- Connect a wire from BUS on the LIN Host click board to BUS on the LIN Client click board
- Connect a wire from GND on the LIN Host click board to GND on the LIN Client click board
- Connect a wire from VS on the LIN Host click board to VS on the LIN Client click board
- Connect the Debug USB port on the board to the computer using a micro USB cable
Running the Application
- Open the Terminal application (Ex.:Tera term) on the computer.
- Connect to the USB Serial COM port and configure the serial settings as
follows:
- Baud: 115200
- Data: 8 Bits
- Parity: None
- Stop: 1 Bit
- Flow Control: None
- Build and Program the application using its IDE.
- The LIN host device communicates with a LIN client device every second to monitor the status of a LED and a switch. The client device sends a data byte indicating the states of both components. The host device evaluates the switch's status: if released, it toggles the LED's state and instructs the client to update the LED. If the switch is pressed, the host activates its own LED without changing the client's LED state.
