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 / AVR PORT pins

AVR PORT pins

|

Microcontroller › AVR › AVR PORT pins

  • This topic has 3 replies, 2 voices, and was last updated 14 years ago by srinu.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 14, 2011 at 11:25 am #1399
    Ashutosh Bhatt
    Participant

    what is the difference between these two instructions

    PORTD| = (1<<PD0) and PORTD = (1<<PD0)?

     

    also what is it mean by PORTD| = (0<<PD0) and PORTD = (0<<PD0) and PORTD& = ~(1<<PD0) ?

    November 16, 2011 at 12:43 pm #6842
    srinu
    Participant

    i think u know the truth table of AND & OR logic

     

    the same opperaton is going on here..

     

    in first two statements..

    PORTD |= (1<<PD0 ) and  PORTD = (1<<PD0) both opperations are same

     

    but in second statemnt(PORTD = (1<<PD0)), we r dng PD0 as a ONE and remaing all pins are ZERO.

     

    in first statemnt (PORTD |= (1<<PD0)), only PD0 as ONE and we r not touching remng PINS..that mean

     

    if  PD1=1,

    in first statemnt PDO=1 and PD1 also 1

    but in second PD0 =1 and PD1 is ZERO.

     

     

    and remaing also same…..

     

     

     

     

    i hope u undersd…………

    November 17, 2011 at 11:40 am #6848
    Ashutosh Bhatt
    Participant

    thanks for the reply

    what happens in proteus simulator that i tell u

     

    if the following code is written to blink the LED then it blinks fine

     

    PORTD = (1<<PD0);

    _delay_ms(1000);

    PORTD = (0<<PD0); 

     

    but if the code is

     

    PORTD|= (1<<PD0);

    _delay_ms(1000);

    PORTD| = (0<<PD0);

     

    then it stays on. no blinking

     

    but again if the code is changed to

     

    PORTD|= (1<<PD0);

    _delay_ms(1000);

    PORTD& = ~(1<<PD0);

     

    led starts blinking

    so my questions is why and how?

     

     

    November 18, 2011 at 4:56 am #6849
    srinu
    Participant

    ok…

    seee here 

    PORTD|= (1<<PD0);

    _delay_ms(1000);

    PORTD| = (0<<PD0);

    ur dng OR operation, means applying LOGICAL OR.

    that mean dng 1 ORING with 0….

    again the result also 1.

     

    that is the reason….

     

    and one more suggetn is give delay after clearing PD0

    means

     

    PORTD|= (1<<PD0);

    _delay_ms(1000);

    PORTD| = (0<<PD0);

    _delay_ms(1000);

     

     

     

    k?

  • 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

  • My Advanced Realistic Humanoid Robots Project December 7, 2025
  • Looking for single photovoltaic cells for light gate December 7, 2025
  • I am ready to move from electrical and electronics field but confused where ? December 7, 2025
  • Hitachi SuperScan Elite 802 CRT Monitor Issues (Model CM802U) December 7, 2025
  • Sanity Check – Peltier "Cooler" for Heating and Cooling December 7, 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