Gentlemen,
I have multiple questions... and I have searched the forums for a specific answer without any luck.
I am trying to learn how to toggle multiple bits on and off without affecting other bits already set. I understand the bitshift part, but not quite have a grasp on the matter.
I am currently setting 2 bits in the same register with two lines of code. It works!
However I want to acomplish the same by using only one line of code which compiles. Dont beat me up because I am not sure of the code below is correct.
Am I doing this right...
Also if I want to set the same bits back to LOW, then is the code below correct?
Also, in the instance of the following where...
How do I write a one liner to do the same...
Thanks in advance
I have multiple questions... and I have searched the forums for a specific answer without any luck.
I am trying to learn how to toggle multiple bits on and off without affecting other bits already set. I understand the bitshift part, but not quite have a grasp on the matter.
I am currently setting 2 bits in the same register with two lines of code. It works!
Code:
GPIOD_PDOR |= (1<<6); // HIGH
GPIOD_PDOR |= (1<<5); // HIGH
However I want to acomplish the same by using only one line of code which compiles. Dont beat me up because I am not sure of the code below is correct.
Code:
GPIOD_PDOR |= ((1<<6) | (1<<5));
Am I doing this right...
Also if I want to set the same bits back to LOW, then is the code below correct?
Code:
GPIOD_PDOR &= ((1<<6) | (1<<5));
Also, in the instance of the following where...
Code:
GPIOD_PDOR &= ~(1<<6); // LOW
GPIOD_PDOR |= (1<<5); // HIGH
How do I write a one liner to do the same...
Thanks in advance