Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .nolist
- .include "m16def.inc"
- .list
- .listmac
- .device ATmega16
- ; // komentarz /* */
- .cseg
- // PC == 0000 z reguły, ale gdyby miało być inaczej
- .org 0x0000;
- // Omijamy wektory przerwań
- jmp 0x0030
- .org 0x0030
- /* ldi r16, 10
- ldi r17, 20
- add r16, r17
- */
- //opóźnianie o 104us
- //stos
- ldi r16, low(RAMEND) // ldi r16, 0x5f
- out SPL, r16
- ldi r16, high(RAMEND) // ldi r16, 0x04
- out SPH, r16
- //kierunek portu B
- ldi r16,0b00000001 //najmłodsza linia jako input, reszta jako output
- out DDRB, r16
- loop:
- call wait_104
- call wait_104
- call wait_104
- call wait_104
- call wait_104
- //bit startu 0
- //ldi r16, 0b00000000
- //out PORTB, r16 alternatywa
- cbi PORTB, 0
- call wait_104
- //wyślij 1
- sbi PORTB, 0
- call wait_104
- //wyślij 0
- cbi PORTB, 0
- call wait_104
- //0
- cbi PORTB, 0
- call wait_104
- //0
- cbi PORTB, 0
- call wait_104
- //1
- sbi PORTB, 0
- call wait_104
- //1
- sbi PORTB, 0
- call wait_104
- //0
- cbi PORTB, 0
- call wait_104
- //0
- cbi PORTB, 0
- call wait_104
- //bit stopu 1
- sbi PORTB, 0
- call wait_104
- jmp loop
- .org 0x100
- wait_104:
- ldi r18, 2
- ldi r19, 17
- L1: dec r19
- brne L1
- dec r18
- brne L1
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement