牛卧堂MCU技术交流

标题: [M3334] Simulating LIN Bus Master Code Using UART [打印本页]

作者: admin    时间: 昨天 14:12
标题: [M3334] Simulating LIN Bus Master Code Using UART
Application
This example code implements LIN bus master transmission and reception using UART1 on the M3334 series microcontroller.
BSP Version
M3334_Series_BSP_CMSIS_V3.00.002
Hardware
NuMaker-M3334KI V2.0

The LIN bus is a UART/SCI-based low-cost interface with a single master and multiple slave
structure. The maximum rate is 20 kbps and 19,200 bps or 9,600 bps is commonly used. Its
frame structure starts at 13 bits of 0 followed by multiple bytes of standard UART
communication: 0x55 + ID + data + checksum. The numbers of data bytes are agreed upon by
both parties, up to 8 bytes. 13 bits 0 + 0x55 + ID is the frame header and can only be sent by
the master. The slave can only send data after receiving a frame header matching its own ID.
Therefore, the master must periodically send frame headers so that the slave can send data
promptly.

This example code implements LIN host functionality using UART. The code defines a list of
six messages sent in a loop at 20 ms intervals timed by a Timer. After a frame header is sent,
if the host should send data next, the host will continue to send data. If the host should receive
data next, it starts receiving data.

You can download the sample code at EC_M3334_UART_LIN_Master_V1.00.







欢迎光临 牛卧堂MCU技术交流 (https://www.nuvoton-mcu.com/) Powered by Discuz! X3.2