如何解决如何在 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
我无法配置输入,因为我无法在 ADCSRA/B 中存储
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。