roboforum.ruТехнический форум по робототехнике. |
|
|
si8:
ldi r16,'1'
SBIS UCSRA,UDRE
RJMP si8
sbi UCSRB, TXB8
OUT UDR, R16
aaa: ldi r16,'2'
SBIS UCSRA,UDRE
RJMP aaa
sbi UCSRB, TXB8
OUT UDR, R16
bbb: ldi r16,'3'
SBIS UCSRA,UDRE
RJMP bbb
sbi UCSRB, TXB8
OUT UDR, R16
ret
.include "m8def.inc"
;инициализация таблицы прерываний
rjmp init
reti
reti
reti
reti
reti
reti
reti
reti
reti
reti
rjmp t1 ;RXCIE(UCSRB) RXC(UCSRA) Прерывания прием по USART завершен.
reti
reti
reti
reti
reti
reti
reti
;======================================================
init: ;инициалищация уарт
LDI r16, low(47)
OUT UBRRL,r16
LDI r16, high(47)
OUT UBRRH,r16
ldi r16,0b11111000
out UCSRB,r16
ldi r16,0b10000110
out UCSRC,r16
;инициализация порта В
ldi r16,0b11111111
out ddrB,r16
ldi r16,0b00000000
out portB,r16
;инициализация порта С
ldi r16,0b11111110
out ddrC,r16
ldi r16,0b00000001
out portC,r16
;разрешения режима sleep
ldi r16,0b00100000
out MCUCR,r16
;инициализация ШИМ
; SBI DDRB,1
SBI DDRB,2
LDI R16,(0<<COM1A1)|(1<<COM1B1)|(1<<WGM10) ; Инициализация PWM
OUT TCCR1A, R16
LDI R16,(1<<WGM12)|(1<<CS10) ; Режим Fast PWM
OUT TCCR1B, R16
LDI R16,0 ; Скважность 0%
OUT OCR1BL,R16
;разрешения прерываний
sei
; укладываем мк спать , подьём по прерыванию.
pause: sleep
rjmp pause
;=========================================================================================
t1: in r16,UDR
uart_snt: SBIS UCSRA,UDRE
RJMP uart_snt
OUT UDR, R16
cpi r16,'k'
breq si8
cpi r16,'z'
breq ledon
cpi r16,'x'
breq ledoff
cpi r16,'+'
breq plus
cpi r16,'-'
breq min
cpi r16,'9'
breq speed9
cpi r16,'1'
breq speed1
cpi r16,'0'
breq speed0
cpi r16,'q'
breq mot1left
cpi r16,'w'
breq mot1stop
cpi r16,'e'
breq mot1right
cpi r16,'a'
breq mot2left
cpi r16,'s'
breq mot2stop
cpi r16,'d'
breq mot2right
reti
;============================================================================================
si8:
ldi r16,'1'
SBIS UCSRA,UDRE
RJMP si8
SBIS UCSRA,TXC
RJMP si8
sbi UCSRA, TXC
OUT UDR, R16
aaa: ldi r16,'2'
SBIS UCSRA,UDRE
RJMP aaa
SBIS UCSRA,TXC
RJMP aaa
sbi UCSRA, TXC
OUT UDR, R16
bbb: ldi r16,'3'
SBIS UCSRA,UDRE
RJMP bbb
SBIS UCSRA,TXC
RJMP bbb
sbi UCSRA, TXC
OUT UDR, R16
reti
ledon: ldi r16,0b00000010
out PORTC,r16
reti
ledoff: ldi r16,0b00000000
out PORTC,r16
reti
plus: in r16,OCR1BL
inc r16
OUT OCR1BL,R16
reti
min: in r16,OCR1BL
dec r16
OUT OCR1BL,R16
reti
speed9: LDI R16,255
OUT OCR1BL,R16
reti
speed1: LDI R16,150
OUT OCR1BL,R16
reti
speed0: LDI R16,0
OUT OCR1BL,R16
reti
mot1left: cbi portC, 5
sbi portC, 4
reti
mot1stop: cbi portC, 4
cbi portC, 5
reti
mot1right: cbi portC, 4
sbi portC, 5
reti
mot2left: cbi portC, 3
sbi portC, 2
reti
mot2stop: cbi portC, 2
cbi portC, 3
reti
mot2right: cbi portC, 2
sbi portC, 3
reti
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 19