why open two LED ....PIC16f877a..

Thread Starter

micro1

Joined Feb 22, 2015
79
hello all

use PIC16f877a in this problem , the language is hi-tech , I did this problem in MPLAN and the simulation in proteus 8, why open two LED and next time two LED ,I write in programing 8 LEDs ,where the problem in program or in proteus?

20150309_172608.jpg 1.PNG 2.PNG

please see my program same the question?

Code:
#include<htc.h>

__CONFIG (FOSC_HS & WDTE_OFF & PWRTE_ON & BOREN_OFF );

#define _XTAL_FREQ 20000000

#define sw1 RB0


void main(void)
{
unsigned char i;

unsigned char j;


TRISD=0b00000000;

PORTD=0b00000000;

TRISB0=1;




if (sw1=0){

while(1){
for(i=0 ;i<2 ;i++)
    {
    PORTD=0b11111111;

    __delay_ms(250);

    PORTD=0b00000000;
    }


    __delay_ms(250);



for(i=0 ;i<2 ;i++)
    {
    PORTD=0b11111111;

    __delay_ms(250);

    PORTD=0b00000000;
    }
  }
}

}
 

tshuck

Joined Oct 18, 2012
3,535
You're program does not include an infinite loop if the switch input =1 when it gets to the if statement.

What happens after your simulated PIC steps beyond the program space is undefined.

I'd suggest you put everything in an infinite loop, and add a pullup on your switch input (it's current states are grounded and floating).
 
Top