element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experts, Learning and Guidance
  • Technologies
  • More
Experts, Learning and Guidance
Ask an Expert Forum Issue with Receiving Structured Data via UART Callback on STM32
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experts, Learning and Guidance to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 9 replies
  • Answers 1 answer
  • Subscribers 284 subscribers
  • Views 1453 views
  • Users 0 members are here
  • usart
  • sensors
  • stm32f407ig
  • stm32
  • uart
  • electronics
  • stm32f4discovery
Related
See a helpful answer?

Be sure to click 'more' and select 'suggest as answer'!

If you're the thread creator, be sure to click 'more' then 'Verify as Answer'!

Issue with Receiving Structured Data via UART Callback on STM32

pooja_14
pooja_14 9 months ago

Hello,

I'm working with two different STM32 microcontrollers:

  • Sender: STM32F4CCUx
  • Receiver: STM32F4VET6

I am sending a packet (which is a structure of size 4) from the sender to the receiver using UART, with both microcontrollers utilizing the UART callback function for transmission and reception.

Here is the process I’m following:

  1. The sender sends a packet using HAL_UART_Transmit_IT.
  2. The receiver is configured with HAL_UART_Receive_IT.
  3. Both microcontrollers handle data in their respective callback functions.

However, on the receiving side, the data is either jumbled or incorrect.

Details:

  • The packet is a structured type with multiple fields.
  • I’ve ensured that the baud rate and UART configurations match on both microcontrollers.
  • The callback functions seem to be triggering correctly.
  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz 9 months ago +1 suggested
    There are a lot of useful examples (google ' STM32 UART interrupt receive example '). It would be best to start with one of those examples, so that you have known working code. Some of those examples…
Parents
  • shabaz
    0 shabaz 9 months ago

    There are a lot of useful examples (google 'STM32 UART interrupt receive example').

    It would be best to start with one of those examples, so that you have known working code. 

    Some of those examples are precisely for the situation where the length of the received data is unknown, i.e. you will be able to view data in a buffer and process it once your code determines a complete set of data has arrived (it is up to your code to decide on that).

    Start with one of the examples, and that will confirm to you that the sender side data is successfully being received correctly. Without that, it's like a stab in the dark.

    Then, code your algorithm to determine when the received data is sufficient to process as a complete message.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • shabaz
    0 shabaz 9 months ago

    There are a lot of useful examples (google 'STM32 UART interrupt receive example').

    It would be best to start with one of those examples, so that you have known working code. 

    Some of those examples are precisely for the situation where the length of the received data is unknown, i.e. you will be able to view data in a buffer and process it once your code determines a complete set of data has arrived (it is up to your code to decide on that).

    Start with one of the examples, and that will confirm to you that the sender side data is successfully being received correctly. Without that, it's like a stab in the dark.

    Then, code your algorithm to determine when the received data is sufficient to process as a complete message.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube