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 / Replies / Hi,Avoid using statements

Hi,Avoid using statements

|

Microcontroller › PIC › confusion in using latch register and port register › Hi,Avoid using statements

December 8, 2014 at 4:50 am #12406
AJISH ALFRED
Participant

Hi,

Avoid using statements like this in your ‘C’ code.

LATB=~LATB 

PORTA=~PORTA 

 

Take a temperory variable, say ‘t’ and convert the above statements like,

 

t = LATB;

LATB = ~t;

 

t = PORTA;

PORTA = ~t;

 

Port registers are connected to the port pin through Latch registers,

 

PORT REGISTER >> LATCH REGISTER >> PORT PIN

 

Even if you write a value to the port register, it will not appear at the port pin until you enable the latching using the lacth registers. 

For a simple LED blinking, writing a ‘1’ or ‘0’ to port register (according to whether the anode or cathode of LED is connected to the pin) and then keep on enabling and disabling the latching will do the purpose.

RSS Recent Posts

  • To couple or decouple February 10, 2026
  • ANOTHER OLD PROJECT REDO February 10, 2026
  • analog logic of shmidt trigger bjt circuit February 10, 2026
  • Buffer design? February 10, 2026
  • XLR splitter to mono. February 10, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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