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

Comments

Popular posts from this blog

HackRF with srsLTE and openlte

Blinking a LED in STM32F103C8T6 (Blue Pill) Board

Read Continuously from Serial Port in QT