I want to activate the 23 pin to light an LED
; Reset Vector
rjmp Start
Start:
ldi r16, 0x00 ;Cargar el registro de trabajo 16 al valor 0
out DDRB, r16 ;Asignar al puerto B el valor del registro 16
ldi r16, 0xFF ;Carga el registro de trabajo 16, el valor FF
out DDRC, r16 ;Asignar al puerto C el valor del registro 16
Loop:
in r16, PINB ;Lee puerto B
out PORTC, r16 ;Escribe en puerto C lo leído
ldi PORTC, 1
rjmp Loop
CodePudding user response:
If you want to enable PC0 (pin 23) output then you need to set bit #0 in both DDRC
(which enables output driver at the pin) and PORTC
(which selects high output level).
You can either use OUT
command to write 8bit value to an I/O register:
ldi r16, 0x01
out PORTC, r16
out DDRC, r16
or you can use sbi
instruction to set a bit in one of first 32 I/O registers:
sbi PORTC, 0
sbi DDRC, 0
CodePudding user response:
How LED on PC0 is connected? Provide schematics. Why D1 is connected to two ports? PC1 and PC5.