Raguvaran
Newbie level 5
Hi, I am in basic level of embedded C. Using Keil for STM32 programming. For bit set and reset i use "|=" and "&=~". Below is a code
GPIOA->ODR |= (1<<5); // PA5 = 1
GPIOA->ODR &=~ (1<<5); // PA5 = 0
While using ARM Compiler Version 5 there is no issue.
In ARM Compiler 6 (ARMClang compiler), I am getting a warning while using "~" that
main.c(28): warning: implicit conversion changes signedness: 'int' to 'unsigned int' [-Wsign-conversion]
GPIOA->ODR &=~ (1<<5); // PA5 = 0
~~^~~~~~~~
By reading a document "Migrate ARM Compiler 5 to ARM Compiler 6", I understood the Bit-field Signedness in ARM Compiler 5 is default unsigned and in ARM Compiler 6 is default signed
My Question is,
1) Now how i have make a bit to zero without using "~" and affecting other bits in a register?
2) Is it ok to use "|=" to make a bit to 1?
3) Is any other effective way to make a bit to zero or one without affecting other bits in a register?
Kindly apology me if my question is very basic,
Thank you in advance
GPIOA->ODR |= (1<<5); // PA5 = 1
GPIOA->ODR &=~ (1<<5); // PA5 = 0
While using ARM Compiler Version 5 there is no issue.
In ARM Compiler 6 (ARMClang compiler), I am getting a warning while using "~" that
main.c(28): warning: implicit conversion changes signedness: 'int' to 'unsigned int' [-Wsign-conversion]
GPIOA->ODR &=~ (1<<5); // PA5 = 0
~~^~~~~~~~
By reading a document "Migrate ARM Compiler 5 to ARM Compiler 6", I understood the Bit-field Signedness in ARM Compiler 5 is default unsigned and in ARM Compiler 6 is default signed
My Question is,
1) Now how i have make a bit to zero without using "~" and affecting other bits in a register?
2) Is it ok to use "|=" to make a bit to 1?
3) Is any other effective way to make a bit to zero or one without affecting other bits in a register?
Kindly apology me if my question is very basic,
Thank you in advance