cancel
Showing results for 
Search instead for 
Did you mean: 

Question about USART??

elaroussi
Associate II
Posted on February 21, 2014 at 16:17

PLz can some one tell me why we must ''&'' the received value with 0x7F!!!!!!

3 REPLIES 3
chen
Associate II
Posted on February 21, 2014 at 17:04

''PLz can some one tell me why we must ''&'' the received value with 0x7F''

There is no absolute need to bit wise AND with 0x7F!

It is probably there to support 7bit data width for the RS232 standard.

Posted on February 21, 2014 at 17:20

It is probably there to support 7bit data width for the RS232 standard.

Or strip parity, ST's definition of data bit includes the parity bit, the USART_DR can contain up to 9-bits. Masking covers a couple of ill's including stopping some compilers warning as you cast from a 16-bit unsigned int to an 8-bit signed/unsigned char.

There is generally much disagreement as to whether a char is signed or unsigned, many compilers/os have their own ideas, with defaults, or overrides.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
elaroussi
Associate II
Posted on February 21, 2014 at 23:31

thks 4 help 🙂