Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Strange behaviour of Atmega8 after setting FUSE bits

Status
Not open for further replies.

hardik.patel

Member level 5
Joined
Aug 15, 2012
Messages
94
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,008
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.
 

Setting the LOW fuse to 0xEF sets the clock for a 3 to 8 megahertz external crystal. Is this what you have in your circuit??

The code you have listed compiles fine but does not seem to work.
You might try the code below as a test.

Code:
#include <avr/io.h>  // header file that enables AVR peripherals
#include <util/delay.h>  // header file to use time delay

int main()
 {
    
           
      DDRB = 0b11110000; //0XFF;//0b0000011;  switch
      DDRC = 0b11111111; // leds
	        
	  
      PORTC= 0x00;  _delay_ms(800); PORTC= 0x00; //_delay_ms(100);
      PORTB = 0xff; 
       
while(1)                         //Never ending loop starts here
      {
      PORTC = ~PINB;   // port b = 1, portc = 0
      }  
 }
 

Setting the LOW fuse to 0xEF sets the clock for a 3 to 8 megahertz external crystal. Is this what you have in your circuit??

I am using 7.3728 Mhz...so for this crystal i think fuse bits value is right.
For 11.0592Mhz as external crystal what is the fuse bits value??

The code you have listed compiles fine but does not seem to work.
You might try the code below as a test.

But, My code is working ok with default fuse bits setting.
 

I ran your code with led's on PORTC with switches that would ground inputs on PORTB when pressed. The LED's did not respond to the switches with your code. I modified your code to the code I suggested you try . With the code I posted the corresponding LED would respond when a switch was pressed. Did you try that code ?? The code you posted was very complicated for the simple task it was designed for.
It looks to me like your fuse settings are OK, and the problem is the code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top