Firmware als Hex-Datei und Quelltext sowie Platinenlayout als Sprint-Layout- und PDF-Datei

1: program EC_Messgeraet_Vers3
2: 'Lutz Henning, DK8JH, 18.02.2021
3: 'PIC 12F675
4: 'Pin1: +5V
5: 'Pin2: Ausgang GPIO5
6: 'Pin3: Ausgang GPIO4
7: 'Pin4: MCLR 4,7 k an +5V
8: 'Pin5: Eingang EC-Messung (AN2)
9: 'Pin6: Ausgang Fernueberwachung
10: 'Pin7: Ausgang anzeige (Messinstrument)
11: 'Pin8: GND
12:
13: ' Declarations section
14: dim n, anzeige as integer
15:
16: sub procedure interrupt	 'Bei TMR0-Interrupt
17: GPIO=GPIO xor %00110000
18: TMR0=127
19: INTCON.T0IF=0
20: end sub
21:
22: main:
23: ' Main program
24: OSCCAL=OSCCAL		'Kalibrierung des internen Oszillators
25: asm					
26: call 0x3ff
27: bsf STATUS,RP1
28: movwf OSCCAL
29: end asm			'Ende Kalibrierung			
30:
31: OPTION_REG=%00000000
32: TRISIO=%11001100		 'GPIO.5 (Pin2), GPIO.4 (Pin3), GPIO.1 (Pin6) und GPIO.0
				 (Piin7) als Output
33: CMCON=%00000111		 'Alle Pins digital
34: GPIO=%00100000 		'Initialisierung GPIO.5 auf "1", übrige auf "0"
35: OPTION_REG=%00001000 	'Einstellung des TMR0 auf 1:256
36: INTCON=%10100000 	'TMR0 Overflow Interrupt enable
37: ANSEL=%01010100 		'Aktivierung AN2
38: ADCON0=%10001011	'Setzen des A/D-Controllregisters für AN2
39: delay_us(100)
40:
41: schleife:
42: ADCON0.1=1		'Setzen des A/D Statusbits
43: while ADCON0.1=1
44: nop
45: wend
46: anzeige=ADRESH*256+ADRESL
47:
48: GPIO.0=0
49: GPIO.1=0
50: for n = 0 to anzeige
51: delay_us(1)
52: next n
53: GPIO.0=1
54: GPIO.1=1
55: for n = 0 to (943-anzeige)
56: delay_us(1)
57: next n
58:
59: goto schleife
60:
61: end.