Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; code ex ample for lab 20
- .nolist ;quartz assumption 4Mhz
- .include "m128def.inc"
- .list
- .ESEG ; EEPROM memory segment
- .DSEG ; SRAM memory.segment
- .ORG 0x100; may be omitted this is default value
- .CSEG ; CODE Program memory. Remember that it is "word" address space
- .org 0x0000
- RESET:
- ldi r16, high(RAMEND); Main program start
- out SPH,r16 ; Set stack pointer to top of RAM
- ldi r16, low(RAMEND)
- out SPL,r16
- cli ; Disable all interrupts
- ;
- ; place here code related to initialization of ports and interrupts
- ;; <instr> xxx ; End of port initialization
- ldi r16,0x00 ;
- out PORTC,r16 ; PORTC - wejscie
- ldi r16,0xFF ;
- out PORTC,r16 ; PORTC - wejscia PULL-UP
- ldi r16,0xFF ;
- out PORTB,r16 ; PORTB - jako wyjscie
- out DDRB,r16 ; PORTB - wyjscie w stanie wysokim
- ;sei ; Enable interrupts
- ;
- ; Main program code place here
- ldi zh, high(tab_ROM<<1)
- ldi zl, low(tab_ROM<<1)
- Main_2:
- ; sprawdzanie przycisku
- in r16, PINC ; pobierz wartosc
- cpi r16, 0xFF ; porownaj z 1
- brsh Main_2 ; brak przycisku
- Main_1:
- movw r18:r19, z ; zapisz z
- ;test for bacaface
- lpm r16, z+
- cpi r16, 0xba ;test na BA
- brne Main_12 ;nie ma BA
- lpm r16, z+
- cpi r16, 0xca ;test na CA
- brne Main_12 ;nie ma CA
- lpm r16, z+
- cpi r16, 0xfa ;test na FA
- brne Main_12 ;nie ma FA
- lpm r16, z
- cpi r16, 0xce ;test na CE
- breq End ;jest CE
- Main_12:
- movw z, r18:r19 ; wczytaj z
- lpm r0, z+
- com r0 ; negacja
- out PORTB, r0 ; wyswietl wartosc
- rjmp Main_1
- ;jmp End ; koniec petli
- ; First load initial values of index registers
- ; Z, X, Y
- ;
- ;----------------------------------------------------------
- ; Ending loop
- ;----------------------------------------------------------
- End:
- rjmp End
- ; place here test values
- ; Test with value 0x8000 also ;
- tab_ROM: .db 0xba, 0xca, 0xfa, 0xce
- .EXIT
- ;b.!face
Add Comment
Please, Sign In to add comment