How to Fix CR/LF Transmission Issues Between MS Excel VBA and STM32 via Serial?
I am trying to exchange data between MS Excel (using VBA) and my STM32 Nucleo board via a serial line (virtual COM port). I am using the Microsoft Datastream add-in, which I believe is designed for this purpose. However, I encountered an issue where the add-in doesn't append CR (0x0D) or LF (0x0A) characters correctly. According to my serial port monitoring software, the add-in always sends 0x0A (LF) at the end, even if it’s not in the message. But if I manually include 0x0D (CR) or 0x0A (LF) in the message, they get omitted. Interestingly, other control characters like 0x09, 0x0B, etc., transmit fine.
Additionally, I'm using Excel version 365 with the Datastream add-in version 1.2. The STM32 device needs these CR/LF characters to process the messages correctly.
Have you encountered this issue or found a way to force the add-in to send CR/LF characters as expected?
Are there any workarounds in VBA to ensure this functionality?
3 Replies
yeh, sure..you can try this. Instead of relying on the Datastream add-in, use VBA to manually append
Chr(13)
(CR) or Chr(10)
(LF) to your message:
Also, On the STM32 side, handle LF (
0x0A
) by detecting it as an end-of-line marker, even if CR (0x0D
) isn't always included. This adds robustness to your data handling.Thanks for the suggestion @Dark AI I’ll try using VBA to manually append the CR and LF characters
I’ll let you know if I need further assistance.