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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
| Main
#DEFINE enable PORTC,2
#DEFINE RW PORTC,1
#DEFINE RS PORTC,0
movlw 0x00
movwf TRISC
movwf TRISD
movlw 0xFF
movwf TRISA
Initialize_LCD
BCF RW ; clear RW
BCF RS ; clear so you can put in instructions
movlw 0x38 ; setting up LCD for 8 bit interface, 2 lines
movwf PORTD ; send to PORTD
call toggle ; calls toggle which sets enable then delays, then clears enable.. (writes commands)
movlw 0x38 ; must send a total of three times to the LCD
movwf PORTD
call toggle
movlw 0x38 ; last time to send to PORTD
movwf PORTD
call toggle
movlw 0x0F ; command for LCD display on cursor blinking
movwf PORTD
call toggle
movlw 0x14 ; move cursor right by one character
movwf PORTD
call toggle
movlw 0x01 ; clear LCD display and DDRAM
movwf PORTD
call toggle
FirstMessage
BSF RS ; setting RS will enable the LCD to accept data inputs
movlw 'T' ; writing a L to the LCD
movwf PORTD
call toggle
movlw 'E' ; writing an E to the LCD
movwf PORTD
call toggle
movlw 'M'
movwf PORTD
call toggle
movlw 'P' ; making a space on the LCD
movwf PORTD
call toggle
movlw ':'
movwf PORTD
call toggle
SetupRegisters
movlw b'10001010'
movwf ADCON2 ; setup ADCON2 to 2Tad and 32 Prescaler TOSC (3.2us acquistion time)
movlw 0x00
movwf ADCON0 ; select channel 0
ADCModule
BSF ADCON0,0 ; turn on the ADC module
BSF ADCON0,1 ; start the conversion
Conversion
btfsc ADCON0,1 ; check conversion
goto Conversion
BCF ADCON0,0 ; turn off the ADC module
movlw ADRESH ; read and move the result
movwf 0x00
movlw ADRESL ; read and move the result
movwf 0x01
BCF RS
movlw 0xC0
movwf PORTD
call toggle
Insert Code for displaying conversion
goto ADCModule
toggle ; toggle commands into LCD
BSF enable ; Make enable high
call delay2 ; call delay
BCF enable ; clear enable
return ; return to code
delay2
movlw 0x9F
movwf count1
movwf count2
indelay2
decfsz count1,1
goto indelay2
decfsz count2,1
goto indelay2
return
delay ; delay for 1s
movlw 0xFF
movwf count1
movwf count2
indelay
decfsz count1,1
goto indelay
decfsz count2,1
goto indelay
return
; *** main code goes here ***
;******************************************************************************
;End of program
stop
END |