Es un espacio donde publico notas que creo interesantes desde octubre de 2007.
jueves, 18 de octubre de 2012
miércoles, 5 de septiembre de 2012
domingo, 15 de julio de 2012
domingo, 3 de junio de 2012
miércoles, 30 de mayo de 2012
Un ejemplo con sl breq
.include "m8535def.inc"
.def a = r16
.def b = r17
.org $0000
ldi a,1
cpi a,1
breq hola ;cuando a y b son iguales breq salta a hola
ldi a,10
hola:
ldi a,11
.def a = r16
.def b = r17
.org $0000
ldi a,1
cpi a,1
breq hola ;cuando a y b son iguales breq salta a hola
ldi a,10
hola:
ldi a,11
viernes, 18 de mayo de 2012
Comunicación serial con salida en el puerto A y entrada en el puerto B
.include "m8535def.inc"
.def temp = r16 ;temporary data
.org $0000
ldi temp,low(RAMEND)
out SPL,temp
ldi temp,high(RAMEND)
out SPH,temp ;init Stack Pointer
ldi temp,255
out DDRA,temp
ldi temp,0
out DDRB,temp
rjmp start ;reset handler
.org URXCaddr ;definition in the
rjmp UART_RX_interrupt ;8515 include file
;receive complete interrupt
UART_RX_interrupt:
in temp ,UDR
out PORTA,temp
rcall transmit
reti
;initialize UART
initialize:
out UBRRL, temp ;init baudrate
;enable receiver, transmitter and TXCint
ldi temp, (1<
out UCSRB, temp
sei ;global interrupt enable
ret
;transmit a byte
transmit:
sbis UCSRA,UDRE ;ready to send?
rjmp transmit
in temp,PINB
out UDR, temp
ret
start:
ldi temp, 25 ;19.200bps@8MHz
rcall initialize
forever:
rjmp forever ;eternal loop
.def temp = r16 ;temporary data
.org $0000
ldi temp,low(RAMEND)
out SPL,temp
ldi temp,high(RAMEND)
out SPH,temp ;init Stack Pointer
ldi temp,255
out DDRA,temp
ldi temp,0
out DDRB,temp
rjmp start ;reset handler
.org URXCaddr ;definition in the
rjmp UART_RX_interrupt ;8515 include file
;receive complete interrupt
UART_RX_interrupt:
in temp ,UDR
out PORTA,temp
rcall transmit
reti
;initialize UART
initialize:
out UBRRL, temp ;init baudrate
;enable receiver, transmitter and TXCint
ldi temp, (1<
sei ;global interrupt enable
ret
;transmit a byte
transmit:
sbis UCSRA,UDRE ;ready to send?
rjmp transmit
in temp,PINB
out UDR, temp
ret
start:
ldi temp, 25 ;19.200bps@8MHz
rcall initialize
forever:
rjmp forever ;eternal loop
Suscribirse a:
Entradas (Atom)