Page 1 of 1

how do I change one single bit?

Posted: Fri Dec 03, 2021 1:21 pm
by HyperUniverse
How do I change one bit inside a uint8_t?

For example I used to do this:

Code: Select all

unsigned char something ;

something.F5 = 0 ;
But I can't get it to work in esp-idf.

Can anybody show me how to do it, please?

Thanks.

Re: how do I change one single bit?

Posted: Fri Dec 03, 2021 6:51 pm
by mgsecord62
In the past I have used the the bitwise OR, AND or XOR operators (standard C language). You can also create a structure. More details can be found at https://www.codesdope.com/blog/article/ ... -bit-in-c/.

Re: how do I change one single bit?

Posted: Sat Dec 04, 2021 9:54 am
by RalphD
http://kali.azc.uam.mx/clc/03_docencia/ ... %2B%2B.pdf

page 13 'bitwise operators

that should help, good luck