EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / what is bit masking?????

what is bit masking?????

|

Microcontroller › AVR › what is bit masking?????

  • This topic has 3 replies, 4 voices, and was last updated 12 years, 4 months ago by Deepak Gupta.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 3, 2011 at 4:01 pm #1376
    D.V.G. Krishna
    Participant

    iam using atmega16 microcontroller

    some one told me that if we want to

    check for a single input pin

    we need bit masking.

     

    what is bit masking??????????? 

    June 10, 2013 at 8:33 am #9931
    Shrikant
    Participant

    hello..

    A bit mask is a variable used with logical operators.

    Assuming you want to read the 5th pin of Portb (actually any port)

    variable=PINB&(1<<PB5) // where pb5 refers to the 5th pin…PINB is used to read the values of a port

    This is your mask.. it stores the value at the 5th pin into the variable

    June 10, 2013 at 1:20 pm #9937
    AJISH ALFRED
    Participant

    Hi,

    It is nothing but any logic which you’ve applied to change the value of any one of the required port bits keeping the values of other bits unchanged.

    June 25, 2013 at 12:03 pm #10029
    Deepak Gupta
    Participant

    Bit masking is used to ignore the status of particular bit.

     

    you can check input status by using ‘&’ operater like “PINC&(1<<PC2)” if you want to read status of PC2 similarly for oter pins.

     

    use ‘|’ or operator for writing a single bit like PORTC |= (1<<PC4) to write logic high at PC4.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • WTB: "The Theory Of Servicing AM, FM, And FM Receivers" by Clarence R. Green and Robert M. Bourque November 10, 2025
  • Anyone In The US Ordered From AliExpress Recently? November 10, 2025
  • Calculation of A Class amplifier November 10, 2025
  • strange laptop problem November 10, 2025
  • restarting this Christmas project November 10, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise