Z
Z
Zolton7772015-03-13 09:59:31
Microcontrollers
Zolton777, 2015-03-13 09:59:31

How to write a program to blink an LED on an Atmel328p controller?

I work in Atmel sudio 6.1, AVR Dragon programmer, Atmel328p chip.
You need to write a program that will blink an LED.
Program code

#define F_CPU 250   //Частота на которой будет работать микроконтроллер. В настройках компилятора указана эта же частота
#include <util/delay.h>   //Библиотека определения функции задержки 
#include <avr/io.h>   //Библиотека прерываний 

 
int main(void)
  {
  
  DDRB = 0x01;
  while(1);

  {
    PORTB |=(1<<PB5);
    _delay_ms(50);
    PORTB &= ~(1<<PB5);
    _delay_ms(50);
  }
  }

The problem is that the program reaches the delay (_delay_ms) and stops there.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question