[英]How to activate a pin in Assembler?
I want to activate the 23 pin to light an LED我想激活 23 针来点亮 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
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).如果要启用 PC0(引脚 23)output,则需要在DDRC
(在引脚上启用 output 驱动程序)和PORTC
(选择高 Z78E6221F6393D41CCE68668 级别)中设置位 #0 You can either use OUT
command to write 8bit value to an I/O register:您可以使用OUT
命令将 8 位值写入 I/O 寄存器:
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
指令在前 32 个 I/O 寄存器之一中设置一个位:
sbi PORTC, 0
sbi DDRC, 0
How LED on PC0 is connected? PC0上的LED如何连接? Provide schematics.提供原理图。 Why D1 is connected to two ports?为什么D1连接到两个端口? PC1 and PC5. PC1 和 PC5。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.