Whats wrong to Atmega8 after setting its FUSE bits as High=D9/Low=E1
Asn per the below code, i just identifying that which switch is pressed by ON particular LED.
Atmega8 does this task perfectly if i set its FUSE bits as defaults, but after setting FUSE bits as High=D9/Low=EF, the i/p function of PORTB is not worked but its glow LED when this line comes to execution--
PORTC= 0xFF; _delay_ms(800); PORTC= 0x00; //_delay_ms(100);
then after its not taking i/p from switches.
H/w is perfect as its work with default FUSE bits so there may be problem with FUSE bits.
Code:
#include <avr/io.h> // header file that enables AVR peripherals
#include <util/delay.h> // header file to use time delay
int main (void) //main program starts here
{
DDRB = 0b11110000; //0XFF;//0b0000011; switch
DDRC = 0b11111111; // leds
//PORTC = 0xFF; // all leds off
PORTC= 0xFF; _delay_ms(800); PORTC= 0x00; //_delay_ms(100);
while(1) //Never ending loop starts here
{
PORTB = 0xFF;
//if(PORTD == 0b11111101) {PORTC = 0b11111101;}
//if(PORTD = 0b11111110) {PORTC = 0b11111110;}
if(PINB == 0b11111110) {PORTC = 0b000001;}
else if(PINB == 0b11111101) {PORTC = 0b000010;}
else if(PINB == 0b11111011) {PORTC = 0b000100;}
else if(PINB == 0b11110111) {PORTC = 0b001000;}
else{;}
//else { PORTC= 0x00; _delay_ms(100); PORTC= 0xFF; _delay_ms(100);}//(PORTD=(0<<PD0)) {PORTC=(1<<PC0)}
}
}
Even i had changed switch to connect at PORTD n LEDS to PORTC...this worked even after FUSE bits chang.
But whats the problem with PORTB, cant able to identify.
- - - Updated - - -
I had changed only LOW fuses ----CKSEL1/CKSEL2/CKSEL3 as UnProgrammed, while HIGH fuse as default.