V
V
Vadimm10012018-04-22 17:50:10
Electronics
Vadimm1001, 2018-04-22 17:50:10

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

3 answer(s)
O
Ocelot, 2018-04-22
@Vadimm1001

Instead of LDI, you need to use the IN instruction. And for output to the register, respectively, OUT.

V
vanyamba-electronics, 2018-04-23
@vanyamba-electronics

The LDI R, N instruction loads the 8-bit value of N into register R.

V
Vadimm1001, 2018-04-28
@Vadimm1001

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 question

Ask a Question

731 491 924 answers to any question