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 / Why when I set any port as

Why when I set any port as

|

Microcontroller › PIC › Novice at Microcontrollers › Why when I set any port as

November 24, 2012 at 5:36 am #8786
Ren
Participant

Why when I set any port as input and I write a condition for the output, I get the output regaurdless of thye condition, for the pic16f690. i.e

my code:

 

#include <htc.h>
#pragma config FOSC=INTRCIO
#pragma config WDTE=OFF
#pragma config PWRTE=OFF
#pragma config MCLRE=ON
#pragma config CP=OFF
#pragma config CPD=OFF
#pragma config BOREN=OFF
#pragma config IESO=OFF
#pragma config FCMEN=OFF

void main(void)
{
  ANSEL=0x00;
  ANSELH=0x00;

  TRISBbits.TRISB4=1;
 // TRISAbits.TRISA1=1;
 // TRISAbits.TRISA2=1;
//  TRISBbits.TRISB5=1;
    TRISC=0;

while (1){    
if (PORTBbits.RB4=1)
(PORTC=0xff);       
}    
}

I get Port c lighting up and no input triggered it.

RSS Recent Posts

  • Solid State DC Circuit Breaker Breakthrough: First Applied to the New Generation of Railway Electric Locomotives December 17, 2025
  • Ceramic capacitors voltage rating December 17, 2025
  • What is involved to convert a small town to fiber optic? December 17, 2025
  • How do I choose the right stepper motor for my DIY 3D printer? December 17, 2025
  • What is this called and what was it for December 17, 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