微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 ACSR 和 ACSRA/B (AVR) 中存储

如何解决如何在 ACSR 和 ACSRA/B (AVR) 中存储

我一直在尝试使用 Proteus 8 和 Arduino ATMega 328P 在 AVR 中制作一个比较器。有人告诉我,比较实际上是由 Arduino 进行的,所以我只需要从该位置获取值,但我无法访问它。我尝试过 LDI、SBI 和 IN/OUT 指令,但没有奏效。

这是我现在的代码

    ;When the voltage on the positive pin AIN0 is higher than the voltage on the negative pin AIN1,the Analog Comparator output,ACO,is set.

;------Preps--------
LDI R16,0xFF    ;16 inFF
LDI R17,0x00    ;17 in00
LDI R18,0x80
LDI R19,0x40
LDI R21,0x20
OUT DDRC,R16    ;C out
;CBR ACSR,0x40  ;Clean the 6th ACSR bit to get the AIN0 input
STS ADCSRA,R18  ;Set the 7th ADCSRA bit (ADEN) to get AIN1 input
STS ADCSRB,R19  ;Set the 6th ADCSRB bit (Acme) to get AIN1 input
;CBR ACSR,0x0D   ;Clean 0,1 and 3 in ACSR to obtain toggle with ACO and disable the interruption
OUT ACSR,R21    ;Clean ACSR register


;----------------------------------------------------*

;----------------------------------------------------*
loop:
    nop
    nop
    IN  R20,ACSR       
    CPI R20,0x80  ;Compare registers r1 and r0
    BREQ aco1      ;If equal
    RJMP aco0      ;IFNE aco0 
    
aco1:
    OUT PORTC,R16 ;Turns on the led
    RJMP loop     ;Goes back to verify if ACO changed

aco0:
    OUT PORTC,R17 ;Turns off the led
    RJMP loop     ;Goes back to verify is ACO changed

Here's the assembly

我无法配置输入,因为我无法在 ADCSRA/B 中存储

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?