<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=1172125" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/yegorich">@yegorich</a> I found the culprit! Two issues:</p>
<ul>
<li>uart_stop() line 171 & 178 should be</li>
</ul>
<pre><code>cr1 &= ~USART_CR1_UE;   // note the ~ should be there in both cases
</code></pre>
<ul>
<li>stopbits seems to be not set correctly, when I change it as follow it works:</li>
</ul>
<pre><code>// cr2 |= stopbits;
cr2 |= USART_CR2_STOP_1;
</code></pre>
<ul>
<li>And of course inverting RX bin was required and you should add while you are at it.</li>
</ul>
<p>I also recommend replacing all numeric constants with actual macro as defined in CMSIS header file. Also not use _M (mask) and use actual bit value (even if it happen to be the same) like:</p>
<pre><code>if (databits == UART_DATABITS_8) {
            //cr1 |= USART_CR1_M;
            cr1 |= USART_CR1_M0;
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/10743#issuecomment-456287509">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AEn7YCN0tRFD9VH4gQlB5PjIdHxACCtoks5vFrIFgaJpZM4Z5HDD">mute the thread</a>.<img src="https://github.com/notifications/beacon/AEn7YN66BzdHfvnfTOUNRPZ89yuKMkT8ks5vFrIFgaJpZM4Z5HDD.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/RIOT-OS/RIOT","title":"RIOT-OS/RIOT","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/RIOT-OS/RIOT"}},"updates":{"snippets":[{"icon":"PERSON","message":"@bluephoton in #10743: @yegorich I found the culprit! Two issues:\r\n- uart_stop() line 171 \u0026 178 should be\r\n```\r\ncr1 \u0026= ~USART_CR1_UE;   // note the ~ should be there in both cases\r\n```\r\n- stopbits seems to be not set correctly, when I change it as follow it works:\r\n\r\n```\r\n// cr2 |= stopbits;\r\ncr2 |= USART_CR2_STOP_1;\r\n```\r\n- And of course inverting RX bin was required and you should add while you are at it.\r\n\r\nI also recommend replacing all numeric constants with actual macro as defined in CMSIS header file. Also not use _M (mask) and use actual bit value (even if it happen to be the same) like:\r\n\r\n```\r\nif (databits == UART_DATABITS_8) {\r\n            //cr1 |= USART_CR1_M;\r\n            cr1 |= USART_CR1_M0;\r\n```"}],"action":{"name":"View Pull Request","url":"https://github.com/RIOT-OS/RIOT/pull/10743#issuecomment-456287509"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/10743#issuecomment-456287509",
"url": "https://github.com/RIOT-OS/RIOT/pull/10743#issuecomment-456287509",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>