[Atmel] 跑一下XMEGA-B1程序(18)CodeVisionAVR之一

[复制链接]
1241|1
 楼主| ddllxxrr 发表于 2016-1-23 18:47 | 显示全部楼层 |阅读模式
CodeVisionAVR是Studio7的一个扩展功能,扩展功能怎么打开在前一个贴子有述:

Stuio7的扩展小部件

我觉得相见恨晚,这个是开发AVR,及Xmega的利器。

下载后安装,我默认安装在C盘,其实装D盘也可。
然后点击运行


我想首先点灯吧:

在file下选new然后建立工程:

出现一个弹出对话框,我当然选XMEGA,确定


然后选择芯片型号

单击左边的系统时钟配置
看一下是选择的内部RC2MHz

然后点左边的PORT
因为本开发板是在PORTB的4-7所以把4-7都选择输出



然后点击上边快捷菜单的有个C标志的图标,产生代码

然后再点击刚才旁边的保存图标:

保存到,自已能记信的目录里边,然后要三个文件名

一个是C文件名,一个是工程文件名,一个是CodeVisionAVR能识别的文件名,我都用一个名first。

然后在Studio7中打开这个工程。选择打开,这时到指定的目录里边就能看到Studio能识别的工程。

然后编译,出现了一个奇怪的弹出窗口,显示编译信息。然后我点下载,可以下载。



但主函数没有用户代码,我查了下它的PORT.c文件,里边是直接寄存器操作,那就直接OUT,就可以了。

程序如下,其实我就添了一句话:

PORTB.OUT=0x00;

程序如下:
  1. /*******************************************************
  2. This program was created by the CodeWizardAVR V3.24
  3. Automatic Program Generator
  4. ?Copyright 1998-2015 Pavel Haiduc, HP InfoTech s.r.l.
  5. http://www.hpinfotech.com

  6. Project :
  7. Version :
  8. Date    : 2016/1/23
  9. Author  :
  10. Company :
  11. Comments:


  12. Chip type               : ATxmega128B1
  13. Program type            : Application
  14. AVR Core Clock frequency: 2.000000 MHz
  15. Memory model            : Small
  16. Data Stack size         : 2048
  17. *******************************************************/

  18. // I/O Registers definitions
  19. #include <io.h>

  20. // Standard Input/Output functions
  21. #include <stdio.h>

  22. // Clock System initialization function
  23. #include "clock_init.h"

  24. // I/O Ports initialization function
  25. #include "ports_init.h"

  26. // Declare your global variables here

  27. void main(void)
  28. {
  29. // Declare your local variables here
  30. unsigned char n;

  31. // Interrupt system initialization
  32. // Optimize for speed
  33. #pragma optsize-
  34. // Make sure the interrupts are disabled
  35. #asm("cli")
  36. // Low level interrupt: Off
  37. // Round-robin scheduling for low level interrupt: Off
  38. // Medium level interrupt: Off
  39. // High level interrupt: Off
  40. // The interrupt vectors will be placed at the start of the Application FLASH section
  41. n=(PMIC.CTRL & (~(PMIC_RREN_bm | PMIC_IVSEL_bm | PMIC_HILVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_LOLVLEN_bm)));
  42. CCP=CCP_IOREG_gc;
  43. PMIC.CTRL=n;
  44. // Set the default priority for round-robin scheduling
  45. PMIC.INTPRI=0x00;
  46. // Restore optimization for size if needed
  47. #pragma optsize_default

  48. // System clocks initialization
  49. system_clocks_init();

  50. // Ports initialization
  51. ports_init();

  52. // Virtual Ports initialization
  53. vports_init();

  54. while (1)
  55.       {
  56.       // Place your code here
  57.           PORTB.OUT=0x00;

  58.       }
  59. }




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
xlhtracy 发表于 2016-1-25 14:30 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:http://shop34182318.taobao.com/ http://shop562064536.taobao.com

2404

主题

7002

帖子

68

粉丝
快速回复 在线客服 返回列表 返回顶部