Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  2. ; 1DT301, Computer Technology I
  3. ; Date: 2017-09-289
  4. ; Author:
  5. ; Christian Fagerholm
  6. ; Amelie Löwe
  7. ;
  8. ; Lab number: 4
  9. ; Title: How to use the PORTs. Digital input/output. Subroutine call.
  10. ;
  11. ; Hardware: STK600, CPU ATmega2560
  12. ;
  13. ; Function: Sending characters from keyboard to the STK600 using interrupts
  14. ;
  15. ;
  16. ; Input ports: None
  17. ;
  18. ; Output ports: on-board LEDs connected to PORTB.
  19. ;
  20. ;
  21. ; Subroutines: If applicable.
  22. ; Included files: m2560def.inc
  23. ;
  24. ; Other information:
  25. ;
  26. ; Changes in program: (Description and date)
  27. ;
  28. ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  29. .include "m2560def.inc"
  30. .def temp = r17
  31. .def char = r16
  32. .equ ubbrval = 12
  33.  
  34. .org 0x00
  35. rjmp setup
  36. .org URXC1addr
  37. rjmp loop
  38.  
  39.  
  40. .org 0x72
  41. setup:
  42.  
  43. ;initiating stack
  44. ldi temp, HIGH(RAMEND)
  45. out SPH, temp
  46. ldi temp, LOW(RAMEND)
  47. out SPL, temp
  48.  
  49.  
  50. ldi temp, 0xFF
  51. out DDRB, temp ; Ports for output
  52.  
  53. ldi temp, 0x55
  54. out PORTB, temp
  55.  
  56. ldi temp, ubbrval ; store prescaler value
  57. sts UBRR1L, temp
  58.  
  59. ldi temp, 0b10011000
  60. sts UCSR1B, temp ; setting TX and RX flags enabled and allowing interrupts
  61. sei
  62.  
  63. start:
  64. nop
  65. rjmp start
  66.  
  67. loop:
  68. lds temp, UCSR1A ; read input
  69. lds char, UDR1 ;Read character in UDR
  70.  
  71. output:
  72. com char
  73. out PORTB, char
  74. com char
  75.  
  76. putChar:
  77. lds temp, UCSR1A
  78. sts UDR1, char ;write character to UDR
  79. reti
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement