Some bit level programming
1) Test bit#7 on the byte (byte name is "character") and sending it to port C pin 9
if(character & 0b00000001)
{ GPIOB->BSRR |= GPIO_BSRR_BS9;}
2) Assigning 1 to nth bit of a byte named "BSRR"
BSRR |= (1<<n)
Assigning 0 to nth bit of a byte named "BSRR"
BSRR |= ~(1<<n)
3) There is no "bool" data type in C. We have to use "uint8_t" as substitute
if(character & 0b00000001)
{ GPIOB->BSRR |= GPIO_BSRR_BS9;}
2) Assigning 1 to nth bit of a byte named "BSRR"
BSRR |= (1<<n)
Assigning 0 to nth bit of a byte named "BSRR"
BSRR |= ~(1<<n)
3) There is no "bool" data type in C. We have to use "uint8_t" as substitute
Comments
Post a Comment