There is a simple project I want to build which consists of five buttons and five leds, two of the buttons that I want to stick to PORTA, require pullups to work as they share a common ground while the rest of the three buttons on PORTC doesn't need pullups. The problem that I am facing is that PORTC works very well. I can control the inputs as well as outputs how I want. But its the PORTA that is not working at all especially the pins RA0 , RA1 & RA2. If I set them to output , the output start flickering but when I set them to input they doesn't read the input. Also the pullups doesn't work as well. But I also think that my pins definitions and pin access is not correct. Please correct me where necessary and tell me what I should do.
Here is the circuit along with the code.(its in proteus actually and not on actual hardware which will be ready after I had tested the code).
I have no problem in programming the logic so I am just including the pin declarations:-
Here is the circuit along with the code.(its in proteus actually and not on actual hardware which will be ready after I had tested the code).
I have no problem in programming the logic so I am just including the pin declarations:-
C:
#define sensor_1 RA1
#define relay RA2
#define sensor_2 RA3
#define led_1 RA4
#define on_button RC0
#define auto_button RC1
#define off_button RC2
#define relay_led RC3
#define power_led RC4
#define led_2 RC5
// Initialize function to configure I/O pins
void initialize(void) {
ANSEL = 0x00;
TRISA = 0x00;
PORTA = 0x00;
// TRISA = 0b001011;
// PORTA = 0x00;
// TRISC = 0b000111;
// PORTC = 0x00;
// PORTAbits.RA0 = 1;
// PORTAbits.RA1 = 1;
// OPTION_REGbits.nRAPU = 0;
// WPUAbits.WPUA0 = 1;
// WPUAbits.WPUA1 = 1;
}
Attachments
-
66.3 KB Views: 2