Atmel Studio 7.0 快速上手指南(基于ASF)

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

      第1步:打开Atmel Studio 7.0
1.1

       第2步:新建工程项目

2.2

2.3

       第3步:选择芯片型号
3

3.3

       第4步:添加ASF 驱动库
 4
4.4
4.5
       第5步:查看ASF驱动使用说明
 5
5,6

       第6步:编写代码
 6
 
源码:

        #include <asf.h> //包含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步:编译并生产烧录文件
7
7.2

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

程序包下载及安装说明:http://atmel.eefocus.com/module/forum/thread-4617-1-1.html

 

更多Atmel及科技资讯请关注:  
Atmel中文官网:http://www.atmel.com/zh/cn/
Atmel技术论坛:http://atmel.eefocus.com/
Atmel中文博客:http://blog.sina.com.cn/u/2253031744
Atmel新浪微博:http://www.weibo.com/atmelcn

猜你喜欢

转载自blog.csdn.net/hubinbin595959/article/details/79150027