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 / how to make PORTB.BIT0=0; and PORTB=0x00; without any libaries

how to make PORTB.BIT0=0; and PORTB=0x00; without any libaries

|

Microcontroller › AVR › how to make PORTB.BIT0=0; and PORTB=0x00; without any libaries

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 2 months ago by Duc Cuong Dinh.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 7, 2016 at 9:13 am #4343
    ahmed
    Participant

    how to make PORTB.BIT0=0; and PORTB=0x00; without any libaries ?

    /* atemga32 */

    // PORTB Address      0x38
    #define PORTB        (*(volatile Reg *) 0x38)

    typedef struct
        {
                unsigned char Bit0:1 ;
                unsigned char Bit1:1 ;
                unsigned char Bit2:1 ;
                unsigned char Bit3:1 ;
                unsigned char Bit4:1 ;
                unsigned char Bit5:1 ;
                unsigned char Bit6:1 ;
                unsigned char Bit7:1 ;
        }Reg;

    int main (void)
        {
            while(1)
            {
                PORTB.Bit2=1;
               /*question here how to write PORTB=0X00; */
            }
            return 0;
        }
     

     

    March 11, 2016 at 4:20 pm #13780
    Duc Cuong Dinh
    Participant

    Dear,

    you can create your own the library for that. However, the MCU will take some time to process, it means that the power will be wasted. Atmege( attiny, or atxmega) use logic switch to turn on or turn off the bit. The reason is that it is already built in assembly instruction set so that MCU can run much faster because of having hardware support.

    Have a nice day

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

RSS Recent Posts

  • LED circuit for 1/6 scale diorama May 14, 2025
  • Electronic board faulty?!? May 13, 2025
  • Can I use this charger in every country? May 13, 2025
  • using a RTC in SF basic May 13, 2025
  • An Update On Tarrifs May 13, 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