Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 0 = 0b00000000 = 0x00
- // 1 = 0b00000001 = 0x01
- // 2 = 0b00000010 = 0x02
- // 3 = 0b00000100 = 0x04
- // 4 = 0b00001000 = 0x08
- // 5 = 0b00010000 = 0x10
- // 6 = 0b00100000 = 0x20
- // 7 = 0b01000000 = 0x40
- // 8 = 0b10000000 = 0x80
- // UBRR = 8000000 / (16 * 1200) - 1 = 415
- // BAUD = 8000000 / (16 * (415 + 1)) = 1200
- .include "m16def.inc"
- .org 0x0000 // kod po adressu 0
- .def temp = r16
- .def data = r17
- .def c1= r19
- .def c2 = r20
- .def c3= r21
- .def c4 = r22
- .def c5= r23
- .def c = r24
- .equ Bitrate = 1200
- .equ UBRR = 415
- ldi temp, high(RAMEND)
- out SPH, temp
- ldi temp, low(RAMEND)
- out SPL, temp
- ldi temp, high(415) //skorost 1200 baud
- out UBRRH, temp
- ldi temp, low(415)
- out UBRRL, temp
- ldi temp, (1 << TXEN) | (1 << RXEN) //vklu4aem peredat4ik i priemnik
- out UCSRB, temp
- ldi temp, (1 << UCSZ1) | (1 << UCSZ0) | (1 << URSEL)
- out UCSRC, temp
- ldi temp, 0x1f
- out DDRA, temp
- ldi temp, 0x00
- out PORTA, temp
- ldi c1, 0b00000001
- ldi c2, 0b00000010
- ldi c3, 0b00000100
- ldi c4, 0b00001000
- ldi c5, 0b00010000
- ldi c, 0
- ldi temp, 0x00
- Proga:
- rcall get_byte
- cpi data, '0'
- breq led_off
- cpi data, '1'
- breq led1_on
- cpi data, '2'
- breq led2_on
- cpi data, '3'
- breq led3_on
- cpi data, '4'
- breq led4_on
- cpi data, '5'
- breq led5_on
- cpi data, '9'
- breq sdvig
- rjmp Proga
- sdvig:
- rol temp
- sbic PINA, 4
- add temp, c1
- out PORTA, temp
- rjmp Proga
- get_byte:
- sbis UCSRA, RXC
- rjmp PC-1
- in data, UDR
- ret
- led_off:
- ldi temp, 0x00
- out PORTA, temp
- rjmp Proga
- ///////////////////////////
- led1_on:
- sbic PINA, 0
- rcall led1_off
- sbis PINA, 0
- add temp, c1
- out PORTA, temp
- rjmp Proga
- led1_off:
- sbic PINA, 0
- sub temp, c1
- out PORTA, temp
- rjmp Proga
- /////////////////////
- led2_on:
- sbic PINA, 1
- rcall led2_off
- sbis PINA, 1
- add temp, c2
- out PORTA, temp
- rjmp Proga
- led2_off:
- sbic PINA, 1
- sub temp, c2
- out PORTA, temp
- rjmp Proga
- ////////////////////////////
- led3_on:
- sbic PINA, 2
- rcall led3_off
- sbis PINA, 2
- add temp, c3
- out PORTA, temp
- rjmp Proga
- led3_off:
- sbic PINA, 2
- sub temp, c3
- out PORTA, temp
- rjmp Proga
- ////////////////////////////
- led4_on:
- sbic PINA, 3
- rcall led4_off
- sbis PINA, 3
- add temp, c4
- out PORTA, temp
- rjmp Proga
- led4_off:
- sbic PINA, 3
- sub temp, c4
- out PORTA, temp
- rjmp Proga
- ////////////////////////////
- led5_on:
- sbic PINA, 4
- rcall led5_off
- sbis PINA, 4
- add temp, c5
- out PORTA, temp
- rjmp Proga
- led5_off:
- sbic PINA, 4
- sub temp, c5
- out PORTA, temp
- rjmp Proga
- ////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement