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

  • 12v battery, 18v magic May 23, 2025
  • JBL charge 4 dead motherboard? May 23, 2025
  • Back to the old BASIC days May 23, 2025
  • Reclaiming missing motherboard header May 23, 2025
  • Need help in repairing a dead motherboard May 23, 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