The Easy Guide to Mastering Bit Manipulation in Embedded C - Part 2

Sdílet
Vložit
  • čas přidán 4. 07. 2024
  • Order your own PCB - PCBWay: pcbway.com/g/2NDSPg
    Learn how to write more efficient code by using Bit Manipulation & Bit Masking in your Embedded projects by watching this intuitive explanation of the following bitwise operators: XOR, Left and Right Shifting
    Texas Instruments MSP430 LaunchPad (US): amzn.to/3KzlePN
    MSP430 Microcontroller Basics - Book (US): amzn.to/2OY8tDT
    Last video: • The Easy Guide to Mast...
    Follow me on Instagram : / thefabytm_yt
    Like me on Facebook : / thefabytm
    Secondary Channel : / morethefabytm
    Follow me on Twitter : / thefabytm
    Try Amazon Prime with a free 30 day trial: amzn.to/2MG3A0T
    Sign up for Airalo (international eSIM plans): www.airalo.com/?rfsn=4268870....
    0:00 Intro
    1:12 What XOR & Bit Shifting are useful for
    3:23 XOR operator
    4:27 Bit Shifting
    5:35 Multiplication and division - bit shifting
    7:35 Logicical Shifting, Arithmetic Shifting, Rotating
    My name is Fabi and I am an Engineer and Tech Enthusiast from Romania. On my CZcams channel I do thorough reviews of gadgets, showcase my programming projects and show you which cars I am driving.
    In today's video we'll talk about bit manipulation and bit masking, more specifically, the XOR or exclusive or operator and bit shifting. In the first part of this video we discussed how to use AND, OR and the COMPLEMENT OPERATOR to read a single or multiple bits out of a register and write either a 1 or a 0 back in a register. It's very important to master these early as working with embedded involves a lot writing bits into registers and checking for bits out of registers. Additionally, bitwise operations are almost guaranteed to come up in technical interviews, due to how often they are used in day to day work by most embedded developers.
    So, what would we use the XOR operator and bit shifting for? XOR is useful for toggling bits, XOR-ing with one will always flip the current value of the bit and bit shifting can be obviously used to shift bits from their current position to another desired position. Another, less obvious use is that it allows for very efficient multiplication and division if multiplying or dividing by a power of 2. Most microcontrollers actually have 3 types of shifting: logical shifting, arithmetic shifting and rotating.

Komentáře • 1

  • @TheFabytm
    @TheFabytm  Před rokem

    Learn more about Embedded Systems through my Embedded Systems Explained series: czcams.com/play/PLeAb9_hv082weQ10WcvFfLBlNcCYXlQ4q.html
    The Easy Guide to Mastering Bit Manipulation in Embedded C - Part 2: czcams.com/video/7LhsxYNAXvw/video.html