i'm facing problem regarding the code that i made for my pic16f627a microcontroller. here are the details so that you may understand exactly what i'm trying to achieve. i have set porta as input and portb as output. when ra0 get high it blinks led at rb0,when ra1 get high it blinks led at rb1,when ra2 get high it blinks led at rb2, when ra3 get high it blinks led at rb3 and when ra4 get high it blinks led at rb4 my code is working great ans exactly as i wanted ra0, ra1, ra2, ra3,,,, but but but the problem arises here is when i make the ra4 pin high it doest light up the led at rb4.. i have checked the code and all the pins and connections too but everything is fine .. the problem is only with the pin ra4 rest of the pins are working great (ra0,ra1,ra2,ra3). i dont know where is the problem... can anyone help me out with this problem.. please guide me regarding the issue... im posting the complete original code below that i wrote for my microcontroller...
#include <xc.h> // Configuration word #pragma config FOSC = INTOSCIO // Internal oscillator #pragma config WDTE = ON // Watchdog Timer disabled #define _XTAL_FREQ 4000000 // 4MHz internal oscillator frequency void main (void) { TRISAbits.TRISA0 = 1; // Set RA0 as input TRISAbits.TRISA1 = 1; // Set RA1 as input TRISAbits.TRISA2 = 1; // Set RA2 as input TRISAbits.TRISA3 = 1; // Set RA3 as input TRISAbits.TRISA4 = 1; // Set RA4 as input TRISBbits.TRISB0 = 0; // Set RB0 as output TRISBbits.TRISB1 = 0; // Set RB1 as output TRISBbits.TRISB2 = 0; // Set RB2 as output TRISBbits.TRISB3 = 0; // Set RB3 as output TRISBbits.TRISB4 = 0; // Set RB4 as output PORTBbits.RB0 = 0; // Initialize RB0 to zero PORTBbits.RB1 = 0; // Initialize RB1 to zero PORTBbits.RB2 = 0; // Initialize RB2 to zero PORTBbits.RB3 = 0; // Initialize RB3 to zero PORTBbits.RB4 = 0; // Initialize RB4 to zero PORTA = PORTB; while(1) { if(PORTAbits.RA0 == 1) { // Blink at 100 ms flash rate with 400 ms gap PORTBbits.RB0 = 1; // Toggle RB0 __delay_ms(200); // Flash rate PORTBbits.RB0 = 0; __delay_ms(200); // Gap PORTBbits.RB0 = 1; // Toggle RB0 __delay_ms(200); // Flash rate PORTBbits.RB0 = 0; __delay_ms(200); // Gap } if(PORTAbits.RA1 == 1) { // Blink at 30 ms flash rate with 30 ms gap PORTBbits.RB1 = 1; // Toggle RB0 __delay_ms(200); // Flash rate PORTBbits.RB1 = 0; __delay_ms(200); // Gap PORTBbits.RB1 = 1; // Toggle RB0 __delay_ms(200); // Flash rate PORTBbits.RB1 = 0; __delay_ms(200); // Gap } if(PORTAbits.RA2 == 1) { // Blink at 100 ms flash rate with 500 ms gap PORTBbits.RB2 = 1; // Toggle RB0 __delay_ms(300); // Flash rate PORTBbits.RB2 = 0; __delay_ms(300); // Gap PORTBbits.RB2 = 1; // Toggle RB0 __delay_ms(300); // Flash rate PORTBbits.RB2 = 0; __delay_ms(300); // Gap } if(PORTAbits.RA3 == 1) { // Blink at 100 ms flash rate with 500 ms gap PORTBbits.RB3 = 1; // Toggle RB0 __delay_ms(500); // Flash rate PORTBbits.RB3 = 0; __delay_ms(500); // Gap PORTBbits.RB3 = 1; // Toggle RB0 __delay_ms(500); // Flash rate PORTBbits.RB3 = 0; __delay_ms(500); // Gap } if(PORTAbits.RA4 == 1) { // Blink at 100 ms flash rate with 500 ms gap PORTBbits.RB4 = 1; // Toggle RB0 __delay_ms(500); // Flash rate PORTBbits.RB4 = 0; __delay_ms(500); // Gap PORTBbits.RB4 = 1; // Toggle RB0 __delay_ms(500); // Flash rate PORTBbits.RB4 = 0; __delay_ms(500); // Gap } } } ```
#pragma config LVP = OFF\$\endgroup\$