March 30, 2014 at 5:50 am #2997yaseen. d. makandarParticipant
Hello .. I’m using pic16f684 microcontroller, pickit3 and XC8 compiler, I written program to flash led for 10 seconds after switch button press but when i burn program on pic it start flashing led continuesly before i pressed button, i used all control instructions such as if, while, switch… even i tryed using pointer which is used in mikroC pro compiler which is also not working, Please can you tell me how to read switch. below is the progam which i burned on pic16f684.
#include<xc.h> // XC general include file
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSCIO 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 and can be enabled by SWDTEN bit of
the WDTCON register)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = ON // RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown Out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
//#define Switch PORTCbits.RC0
#define _XTAL_FREQ 4000000 // Set xtal frequency for time delay
unsigned int i;
CMCON0 = 0x07; // turn off comparator
ANSEL = 0b00000000; //All I/O pins are configured as digital
TRISC = 0b00000111; // PORTC All Outputs
TRISA = 0b00001000; // PORTA All Outputs, Except RA3,
PORTA = 1;
PORTA = 0;
}March 31, 2014 at 4:46 am #11426Ashutosh BhattParticipant
u r reading “switch” but what is switch?
u hv commented it out in your program. see ur code.
u r not polling pin status in continuous loop the actual loop should be
PORTA = 1;
PORTA = 0;
- You must be logged in to reply to this topic.