基于ASF的Atmel Studio 7.0使用方法介绍

电子说

1.2w人已加入

描述

就在最近,Atmel终于推出了新版本IDE——Atmel Studio 7.0,该版本采用了微软最新的 Visual Studio 2015 平台,在速度、性能和代码视觉风格上都体现的淋淋尽致,用起来非常顺手,下面将结合实例,介绍Atmel Studio 7.0 的使用方法。

第1步:打开Atmel Studio 7.0

Atmel

第2步:新建工程项目

Atmel

Atmel

第3步:选择芯片型号

Atmel

Atmel

第4步:添加ASF 驱动库

Atmel

Atmel

Atmel

第5步:查看ASF驱动使用说明

Atmel

Atmel

第6步:编写代码

Atmel

源码:

#include //包含Atmel MCU软件库头文件

#define LED PIN_PC27 //定义LED所使用的IO口为 PC27

#define KEY PIN_PC01 //定义KEY所使用的IO口为 PC01

void port_init(void); //声明函数体

/************************************************************************/

//* IO 初始化

/************************************************************************/

void port_init(void)

{

struct port_config config_port_pin;

port_get_config_defaults(&config_port_pin);

config_port_pin.direction = PORT_PIN_DIR_OUTPUT; //配置IO口方向为输出

port_pin_set_config(LED, &config_port_pin); //初始化LED对应IO口

config_port_pin.direction = PORT_PIN_DIR_INPUT; //配置IO口方向为输入

config_port_pin.input_pull = PORT_PIN_PULL_UP; //配置IO口上拉

port_pin_set_config(KEY, &config_port_pin); //初始化KEY对应IO口

}

/************************************************************************/

//* 主程序

/************************************************************************/

int main (void)

{

system_init(); //系统初始化

/* Insert application code here, after the board has been initialized. */

port_init(); //IO初始化

while(1)

{

if (port_pin_get_input_level(KEY) == 0) //KEY按下,LED对应IO电平 = 0

{

port_pin_set_output_level(LED, 0);

}

else

{

port_pin_set_output_level(LED, 1);

}

}

}

第7步:编译并生产烧录文件

Atmel

Atmel

第8步:烧录文件到开发板

Atmel

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分