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
- ;
- ;
- ; 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 start
- .org 0x30
- setup:
- 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, (1<<TXEN1) | (1<<RXEN1)
- sts UCSR1B, temp ; setting TX and RX flags enabled
- start:
- lds temp, UCSR1A ; read input
- sbrs temp, RXC1 ; RXC1 = 1 => new character
- rjmp start ; RXC1 = 0 => no character
- lds char, UDR1 ;Read character in UDR
- output:
- com char
- out PORTB, char
- com char
- putChar:
- lds temp, UCSR1A
- sbrs temp, UDRE1 ;UDRE1=1 == buffer empty
- rjmp putChar ;UDRE1=0 ==buffer not empty
- sts UDR1, char ;write character to UDR
- rjmp start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement