Answer the question
In order to leave comments, you need to log in
Can't read AVR PINx port value?
It doesn't work out, everything has tried all the ways and Hi-Z.
Testing in Proteus. Here is the simplest code:
start:
ldi r16, pinb
rjmp start
In the proteus, register r16 is always 16hex. If you read other ports, then the values \u200b\u200bare slightly different from port B. Even if a voltage of 5 Volts is applied to the outputs, it is still the same value of 16hex.
Answer the question
In order to leave comments, you need to log in
Instead of LDI, you need to use the IN instruction. And for output to the register, respectively, OUT.
The LDI R, N instruction loads the 8-bit value of N into register R.
Well, the pinb register is also 8-bit. Why is the wrong value loaded into the register when using LDI ?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question