# Atmel ATMega8 doesn't hold "HIGH" state of PB0 and PB1

I'm new in microcontrollers and I wrote simple program that set HIGH state at PB0 and PB1.

#include <avr/io.h>
#include <util/delay.h>

#define F_CPU 8000000L

int main(void){
DDRB |= (1<<PB0) | (1<<PB1);
PORTB |= (1<<PB1);
PORTB |= (1<<PB0);

while(1){}
}


The problem is that my avr can't hold on HIGH state and connected leds are blinking. Where is the problem ?

• What does your circuit look like? How do you know the MCU isn't just constantly resetting? How are the LEDs connected, and are you sure they aren't blinking LEDs? May 24, 2017 at 22:24
• Can you describe how the LEDs blink? Do you have a scope and can you probe the power and LED pins? Oh, and please add a schematic. May 25, 2017 at 1:09

You can try calling wdt_disable() at the beginning (it is defined in <avr/wdt.h>), as the watchdog can be enabled for example by previous firmware (watchdog is not disabled after a reset) or can be by always enabled at reset.
There is also a fuse setting that does not allow disabling of the watchdog - you have to call wdt_reset() somewhere in the main loop.