This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

bit masking

Other Parts Discussed in Thread: TM4C123GH6PGE

hi i am a bit confused about bit masking..so suppose if i set

GPIO_PORTF_DEN_R&=~0x0008;

would only bit 3 be modified? isn't it the purpose of using masking in the first place?

thanks

  • You are correct.  Bit 3 would be cleared.  All other bits would remain the same value.

    Bit masking does not apply to this register.

    For access to the data bits, there is a block of address from offset 0x000 to 0x3FC from the beginning of the GPIO port base address.  When you access the GPIO data register, the bits in the address from bits9:2 define which data bits (7:0) are accessed.  For example, if you accessed the PORTF data register using the address 0x4005D3FC, all 8 data bits would be accessed and/or modified.

    However, if you access the data register using 0x400FD004, only bit 0 of the GPIO port would be accessed or modified.

    This bit masking only applies to the GPIO data port register.  More details may be found in the GPIO chapter, in the Functional Description section, in the sub-section Data Register Operation.

    --Bobby

  • Yes - what you wrote will clear bit_3 in GPIO_PORTF_DEN_R,

    You may also set the bit in a similar way:
    GPIO_PORTF_DEN_R |= 0x0008;

    You probably have proper include file to define the register aggress; it might be 

    #include "inc\tm4c123gh6pge.h" 
    or whatever CPU variant you are using.

    Good luck - Martin

  • Well - Bobby was faster and more compehencive with his answer ;-)

    Happy Friday!
    Martin