avr gnu toolchain 开发环境

mplab x and Atmel Studio

Copy the .\avr\include\avr folder from avr8-gnu-toolchain-4.0.0.52-win32.any.x86_64.zip to .\avr\include

MPLAB X v6.35 - Toolchain

Tools -> Options -> Embedded

Add (Base Directory):

C:\Users\tdtc\Programs\avr8-gnu-toolchain\bin

Microchip Studio(Atmel Studio) - Toolchain

Tools -> Options -> Toolchain
Package Configuration

xc8 (update)

Toolchains: Microchip XC8 AVR 8-bit (C language)

安装as7时,取消xc8的安装

avr8-gcc (update)

Toolchains: Atmel AVR 8-bit (C language)

Replaced - other way

removed “avr8-gnu-toolchain” at:

C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\

copy new version avr8-gnu-toolchain.

Device Pack Manager

  • list issue
    A network proxy must be set up.
  • install issue
    First, select the version you want to install; then, click “Install” -> “Install selected package”.

network proxy

Tools -> Options -> Web Browser

Go to “Internet Explorer Options” settings.

offline install

Download from the ATMEL Packs Repository.

example

atmega4809:

#define F_CPU 3333333UL
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    PORTD.DIR |= PIN5_bm;

    while (1)
    {
        _delay_ms(500);
        PORTD.OUT |= PIN5_bm;
        _delay_ms(500);
        PORTD.OUT &= ~PIN5_bm;
    }

    return 0;
}

The macro F_CPU specifies the CPU frequency to be considered by the delay macros.

Ref