搜索
bottom↓
回复: 2

AVR I/O简单汇编计数程序问题

[复制链接]

出0入0汤圆

发表于 2014-2-23 10:35:42 | 显示全部楼层 |阅读模式
编译一个简单AVR汇编,在AVR STUDIO 6编译出错:WHY?
编译出错信息:
invalid redefinition of "PORTB"
invalid redefinition of "DDRB"

程序如下:
;Illustrate_PORT_Output_and_Counting.asm
;Counter - A simple AVR program to illustrate output to a port
;Designed to be executed in a simulator under debug control

;This program counts from 0 to 255 (and repeats)
;The current counter value is output to PORTB of an ATmega16A

;Progarmmer: TM
;Date: 2/2014
;Platform: STK-500
;Device: ATmega16A

.cseg                ;select current segment as code
.org 0                ;begain assembling at address 0

;Define symbolic names for resources used
.def  count =r16                        ;Reg 16 will hold counter value
.def  temp  =r17                        ;Reg 17 is used as a temporary register

.equ  PORTB =0x18                        ;Port B's output register
.equ  DDRB  =0x17                        ;Port B's Data Direction Register

           ldi   temp, 0xFF                ;configure PORTB as ouput
           out         DDRB, temp
          
           ldi   count, 0x00        ;Initialize count at 0

lp:

           out    PORTB, count  ;Put counter value on PORT B
           inc    count                        ;increment counter

           rjmp   lp                        ;repeat (forever)

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

发表于 2014-3-1 15:38:06 | 显示全部楼层
你重复定义了PORTB和DDRB

.equ  PORTB =0x18                        ;Port B's output register
.equ  DDRB  =0x17                        ;Port B's Data Direction Register
屏蔽掉看看

出0入0汤圆

 楼主| 发表于 2014-3-1 19:17:58 | 显示全部楼层
waothom 发表于 2014-3-1 15:38
你重复定义了PORTB和DDRB

.equ  PORTB =0x18                        ;Port B's output register

这位兄台说的对,屏蔽后ok,看样子在AVR Studio6 已经定义好了~谢谢!
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 00:21

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表