1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
.include "tn85def.inc"
.def tmp0 = r16
.def tmp1 = r17
.def tmp2 = r18
.def tmp3 = r19
.equ OFFSET_TEMP = 852
; Interrupt vectors
.org 0x0000
interrupts:
rjmp init
.org INT_VECTORS_SIZE
init:
; Initialize stack pointer
ldi tmp0, HIGH(RAMEND)
out SPH, tmp0
ldi tmp0, LOW(RAMEND)
out SPL, tmp0
;ldi tmp0, 0b01000000
;out MCUCR, tmp0
; Set pin directions
ldi tmp0, 0b00010010
out DDRB, tmp0
; Set default outputs
;ldi tmp0, 0b00000010
;out PORTB, tmp0
; Initialize timers
; Timer configuration:
; Timer 0: Disabled
; Timer 1: Fast PWM mode
ldi tmp0, 0b01100111
out TCCR1, tmp0
ldi tmp0, 0b01100000
out GTCCR, tmp0
; Enable interrupts
;ldi tmp0, 0b10000000
;out SREG, tmp0
; Initialize ADC
ldi tmp0, 0b01000001
out ADMUX, tmp0
ldi tmp0, 0b10000100
out ADCSRA, tmp0
ldi tmp0, 255 - LOW(OFFSET_TEMP)
out OCR1C, tmp0
main:
; Start ADC conversion
sbi ADCSRA, ADSC
capture:
sbic ADCSRA, ADSC
rjmp capture
; Read out ADC
in tmp0, ADCL
; Substract offset
subi tmp0, LOW(OFFSET_TEMP)
; Set as timer compare
out OCR1A, tmp0
com tmp0
subi tmp0, LOW(OFFSET_TEMP)
out OCR1B, tmp0
rjmp main
|