Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] help please Problem with PORTB when using TMR0 on pic16f877A

Status
Not open for further replies.

shaolinyo

Newbie level 6
Joined
Aug 9, 2018
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
102
hello, i used tmr0 for timing , i dont use portb , but when i run the simlation i get that portB is set with a value 1

pic.JPG


and that is the code:

Code:
 int t=0;   //time counter

void interrupt()
{
  if(INTCON.T0IF){
          t++;      //for evry inettruption occure we increment t
          TMR0=150;//the value to start the tmr0 if is spesified in the main program
}

  INTCON.T0IF=0;

}
void main() {


Option_Reg=0b00010000;
INTCON=0b10100000;


trisc=0;
portc=0;


TMR0=150;
for(;;){

       if(t==1)
           portc.rc1=0;
       if(t==2) {
        portc.rc1=1;
        t=0;

       }


}

}


thank you
 

You have Bit 7 (-RBPU) of OPTION_REG programmed to zero, that turns on the internal pull-up sources to PORTB and will make any pin not actively driven low appear to have a high logic level on it.

Try changing OPTION_REG to 0b10010000 and see if it fixes the problem.

Brian.
 
Hi,

"Pullup" is not that bad.

General rule: Don't let (unused) pins floating. This is true for any circuit, digital as well as analog.

Klaus
 

    V

    Points: 2
    Helpful Answer Positive Rating
KlausST thank you for the advice , but what you mean by pins floating , and what is its impact on the circuit?
 

Hi,

but what you mean by pins floating
"floating" is a quite commom phrase.
"floating" = "high impedance" = not driven by anything. No internal drive, no external drive (like pullup, or pulldown).

and what is its impact on the circuit?
This has been discussed many times before:
* Increased supply current
* oscillations
* no valid state
* increased EMI
* EMC problems
*...

Klaus
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top