问题描述
我一直在尝试使用 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 (将#修改为@)