Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ; 1DT301, Computer Technology I
- ; Date: 2017-09-289
- ; Author:
- ; Christian Fagerholm
- ; Amelie Löwe
- ;
- ; Lab number: 4
- ; Title: How to use the PORTs. Digital input/output. Subroutine call.
- ;
- ; Hardware: STK600, CPU ATmega2560
- ;
- ; Function: Sending characters from keyboard to the STK600 using interrupts
- ;
- ;
- ; Input ports: None
- ;
- ; Output ports: on-board LEDs connected to PORTB.
- ;
- ;
- ; Subroutines: If applicable.
- ; Included files: m2560def.inc
- ;
- ; Other information:
- ;
- ; Changes in program: (Description and date)
- ;
- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- .include "m2560def.inc"
- .def temp = r17
- .def char = r16
- .equ ubbrval = 12
- .org 0x00
- rjmp setup
- .org URXC1addr
- rjmp loop
- .org 0x72
- setup:
- ;initiating stack
- ldi temp, HIGH(RAMEND)
- out SPH, temp
- ldi temp, LOW(RAMEND)
- out SPL, temp
- ldi temp, 0xFF
- out DDRB, temp ; Ports for output
- ldi temp, 0x55
- out PORTB, temp
- ldi temp, ubbrval ; store prescaler value
- sts UBRR1L, temp
- ldi temp, 0b10011000
- sts UCSR1B, temp ; setting TX and RX flags enabled and allowing interrupts
- sei
- start:
- nop
- rjmp start
- loop:
- lds temp, UCSR1A ; read input
- lds char, UDR1 ;Read character in UDR
- output:
- com char
- out PORTB, char
- com char
- putChar:
- lds temp, UCSR1A
- sts UDR1, char ;write character to UDR
- reti
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement