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.

example

Atmel.AVR-Dx:

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

int main(void)
{
    CCP = CCP_IOREG_gc; // Protected write
    CLKCTRL.OSCHFCTRLA = CLKCTRL_FRQSEL_24M_gc; // Set clock to 24MHz
    
    PORTD.DIR = 0xFF;

    while (1)
    {
        _delay_ms(500);
        PORTD.OUT = 255;
        _delay_ms(500);
        PORTD.OUT = 0;
    }
}

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

Ref