{"id":4069,"date":"2025-12-13T04:14:38","date_gmt":"2025-12-13T04:14:38","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=4069"},"modified":"2025-12-13T04:14:40","modified_gmt":"2025-12-13T04:14:40","slug":"revisedstm32-uart-part-9-lin-bus-receiving-data","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=4069","title":{"rendered":"[Revised]STM32 UART Part 9: LIN Bus Receiving Data"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2.webp\" alt=\"\" class=\"wp-image-3292\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2.webp 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2-300x300.webp 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2-150x150.webp 150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2-768x768.webp 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2-750x750.webp 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2-400x400.webp 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/DALL\u00b7E-2025-03-01-16.00.55-A-cover-image-for-a-technical-guide-on-LIN-Local-Interconnect-Network-bus-using-STM32F4.-The-image-should-feature-an-STM32F4-microcontroller-with-hi-2-250x250.webp 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In this guide, we shall see how to receive data using UART in LIN configuration.<\/p>\n\n\n\n<p>In this guide, we shall cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>STM32CubeMX setup.<\/li>\n\n\n\n<li>Firmware modification.<\/li>\n\n\n\n<li>Hardware connection.<\/li>\n\n\n\n<li>Results.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">1. STM32CubeMX Setup:<\/h2>\n\n\n\n<p>We shall pickup from the previous guide from <a href=\"https:\/\/blog.embeddedexpert.io\/?p=4032\" data-type=\"link\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=4032\">here<\/a>.<\/p>\n\n\n\n<p>Open LIN_Bus project from STM32CubeMX.<\/p>\n\n\n\n<p>Once the project has been opened, enable USART6 in LIN mode as follows:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-1024x662.jpg\" alt=\"\" class=\"wp-image-4070\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-1024x662.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-300x194.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-768x497.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-1536x993.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-2048x1324.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-1150x744.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-750x485.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-400x259.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-13-250x162.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This will enable PC6 and PC7 for USART6_TX and USART_RX respectively.<\/p>\n\n\n\n<p>Next, from NVIC Settings, enable global interrupt for USART6, once it has been enabled, click on generate code as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-1024x662.jpg\" alt=\"\" class=\"wp-image-4071\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-1024x662.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-300x194.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-768x497.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-1536x993.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-2048x1324.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-1150x744.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-750x485.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-400x259.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-08-27-250x162.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Firmware Modification:<\/h2>\n\n\n\n<p>Once the project has been generated, open the project in STM32CubeIDE.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Open LIN.h header and declare the checksum function as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t checksum_Calc (uint8_t PID, uint8_t *data, int size);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>In the source LIN.c file, modify the following function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static uint8_t checksum_Calc (uint8_t PID, uint8_t *data, int size)<\/pre><\/div>\n\n\n\n<p>To become:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t checksum_Calc (uint8_t PID, uint8_t *data, int size)<\/pre><\/div>\n\n\n\n<p>This will allow us to access the function from another source files.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, in main.c source file, in user code PV section, declare the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t data_rx[20];\n\nuint8_t LIN_Rx_Data[8];<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>data_rx is the buffer to receive LIN frame data.<\/li>\n\n\n\n<li>LIN_Rx_Data is the 8 received bytes.<\/li>\n<\/ul>\n\n\n\n<p>Also, declare the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint32_t previous_ticks=0;\n\nuint8_t numDataBytes;\n\nvolatile uint8_t isDataValid;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>previous_ticks which store the ticks.<\/li>\n\n\n\n<li>numDataBytes is the amount of received data.<\/li>\n\n\n\n<li>isDataValid indicates the success of reception of the data.<\/li>\n<\/ul>\n\n\n\n<p>In user code begin 0:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)\n{\n\t numDataBytes = Size - 4;\n\tuint8_t checksum = checksum_Calc(data_rx[2], data_rx+3, numDataBytes);\n\tID = data_rx[2]&amp;0x3F;\n\tif (checksum != data_rx[Size-1])\n\t{\n\t\tisDataValid = 0;\n\n\t}\n\telse\n\t{\n\t\tisDataValid = 1;\n\t}\n\tHAL_UARTEx_ReceiveToIdle_IT(&amp;huart6, data_rx, 20);\n}<\/pre><\/div>\n\n\n\n<p>This function is a UART receive callback used with the STM32F4 HAL driver when&nbsp;<strong>Receive-to-IDLE interrupt mode<\/strong>is enabled.<\/p>\n\n\n\n<p>The callback&nbsp;<code>HAL_UARTEx_RxEventCallback()<\/code>&nbsp;is automatically called by the HAL when the UART detects an&nbsp;<strong>IDLE line condition<\/strong>, meaning that a complete frame has been received or the sender has stopped transmitting.<\/p>\n\n\n\n<p>The parameter&nbsp;<code>Size<\/code>&nbsp;represents the&nbsp;<strong>number of bytes actually received<\/strong>&nbsp;before the IDLE condition occurred.<\/p>\n\n\n\n<p>The line:<\/p>\n\n\n\n<p><code>numDataBytes = Size - 4;<\/code><\/p>\n\n\n\n<p>indicates that the communication protocol reserves&nbsp;<strong>4 bytes for non-payload data<\/strong>, such as header, ID, control fields, and checksum. The remaining bytes are considered payload data.<\/p>\n\n\n\n<p>Next, a checksum is calculated:<\/p>\n\n\n\n<p><code>checksum_Calc(data_rx[2], data_rx + 3, numDataBytes);<\/code><\/p>\n\n\n\n<p>Here:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>data_rx[2]<\/code>\u00a0is likely a command or device ID field.<\/li>\n\n\n\n<li><code>data_rx + 3<\/code>\u00a0points to the beginning of the payload.<\/li>\n\n\n\n<li><code>numDataBytes<\/code>\u00a0specifies how many payload bytes are included in the checksum calculation.<\/li>\n<\/ul>\n\n\n\n<p>The device ID is then extracted using:<\/p>\n\n\n\n<p><code>ID = data_rx[2] &amp; 0x3F;<\/code><\/p>\n\n\n\n<p>The bitmask&nbsp;<code>0x3F<\/code>&nbsp;keeps only the lower 6 bits of the ID field, discarding any control or flag bits stored in the upper bits.<\/p>\n\n\n\n<p>The received checksum (last byte of the frame) is compared with the calculated checksum:<\/p>\n\n\n\n<p><code>data_rx[Size - 1]<\/code><\/p>\n\n\n\n<p>If the two values do not match, the received data is marked as invalid. Otherwise, it is marked as valid.<\/p>\n\n\n\n<p>Finally, UART reception is restarted:<\/p>\n\n\n\n<p><code>HAL_UARTEx_ReceiveToIdle_IT(&amp;huart6, data_rx, 20);<\/code><\/p>\n\n\n\n<p>This re-arms USART6 to receive the next frame using IDLE line detection, with a maximum buffer size of 20 bytes.<\/p>\n\n\n\n<p>In summary, this callback:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Handles variable-length UART frames<\/li>\n\n\n\n<li>Extracts payload and ID information<\/li>\n\n\n\n<li>Verifies data integrity using a checksum<\/li>\n\n\n\n<li>Automatically restarts reception for continuous communication<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>In user code begin 2 in main function, start the USART6 to receive data until IDLE detected as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">HAL_UARTEx_ReceiveToIdle_IT(&amp;huart6, data_rx, 20);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>In user code begin 3 in while 1 loop:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\t  if(HAL_GetTick()-previous_ticks&gt;100)\n\t  {\n\t\t  for (int i=0;i&lt;8;i++)\n\t\t  {\n\t\t\t  data[i]=random()%255;\n\t\t  }\n\t\t  ID=random()%255;\n\n\t\t  LIN_State=LinTransmit(ID,data);\n\n\t\t  if(LIN_State==Timeout)\n\t\t  {\n\t\t\t  uint16_t len=sprintf(uart_data,&quot;Timeout communication\\r\\n&quot;);\n\t\t\t  HAL_UART_Transmit(&amp;huart2, uart_data, len, 1000);\n\n\t\t  }\n\n\t\t  if(LIN_State==InvalideID)\n\t\t  {\n\t\t\t  uint16_t len=sprintf(uart_data,&quot;Invalid ID\\r\\n&quot;);\n\t\t\t  HAL_UART_Transmit(&amp;huart2, uart_data, len, 1000);\n\t\t  }\n\n\t\t  previous_ticks=HAL_GetTick();\n\n\t  }\n\n\t  if(isDataValid==1)\n\t  {\n\t\t  uint16_t len=sprintf(uart_data,&quot;LIN Data Received\\r\\n&quot;);\n\t\t  HAL_UART_Transmit(&amp;huart2, uart_data, len, 1000);\n\n\t\t  for (int i=0; i&lt;numDataBytes; i++)\n\t\t  {\n\t\t\t  LIN_Rx_Data[i] = data_rx[i+3];\n\t\t  }\n\t\t  isDataValid = 0;\n\t  }<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Save the project, build it and run it in debugging mode on your STM32F4 board.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"38\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-1024x38.jpg\" alt=\"\" class=\"wp-image-3296\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-1024x38.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-300x11.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-768x29.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-1536x57.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-1150x43.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-750x28.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-400x15.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27-250x9.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-56-27.jpg 1878w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Hardware Setup:<\/h2>\n\n\n\n<p>The connection is as simple as connecting PC7 to PA9 using jumper wire as following:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"826\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-1024x826.jpg\" alt=\"\" class=\"wp-image-3297\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-1024x826.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-300x242.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-768x619.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-1536x1239.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-2048x1652.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-1150x928.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-750x605.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-400x323.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/03\/2025-03-15_10-58-46-250x202.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Simply, connect a wire from D8 to D9 of the arduino header.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Results:<\/h2>\n\n\n\n<p>In live expression of the debug session, add data and LIN_Rx_Data to live expression.<\/p>\n\n\n\n<p>Run the project, you should see from time to time there is incoming data as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"654\" height=\"834\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/ezgif-459dfaeba97bc1e6.gif\" alt=\"\" class=\"wp-image-4072\" \/><\/figure>\n\n\n\n<p>Using serial terminal application, you should see the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"733\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-1024x733.jpg\" alt=\"\" class=\"wp-image-4073\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-1024x733.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-300x215.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-768x550.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-1150x823.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-750x537.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-400x286.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01-250x179.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-13_06-38-01.jpg 1168w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We have successfully received LIN also, transmitted data and prevent incorrect ID to be send.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Happy coding \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we shall see how to receive data using UART in LIN configuration. In this guide, we shall cover the following: 1. STM32CubeMX Setup: We shall pickup from the previous guide from here. Open LIN_Bus project from STM32CubeMX. Once the project has been opened, enable USART6 in LIN mode as follows: This will [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12],"tags":[],"class_list":["post-4069","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4069"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4069"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4069\/revisions"}],"predecessor-version":[{"id":4074,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4069\/revisions\/4074"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}