Tengo el siguiente programa:
Código: Seleccionar todo
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
#pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
#include <xc.h>
#include <pic16f628a.h>
#define _XTAL_FREQ 4000000
void main(void)
{
TRISA=0b11111111; //Configurado como entrada
TRISB=0b00000000; //Configurado como salida
CMCON=0b00000111; //Apaga comparadores: Entradas digitales
PORTB=0b00000000;
while(1)
{
if(RA0==1)
{
PORTB=0b11111111;
__delay_ms(300);
PORTB=0b00000000;
__delay_ms(300);
}
else
{
PORTB=0b00000000;
}
}
return;
}
pero si cambio el orden de que primero apaguen y despues prendan, el programa funciona correctamente y no entiendo el por que..
Código:
Código: Seleccionar todo
if(RA0==1)
{
PORTB=0b00000000;
__delay_ms(300);
PORTB=0b11111111;
__delay_ms(300);
}
PD: al simular ambos programa en proteus funciona perfectamente los 2.