1 | ;--PORTA ;S.11 Pin Out description
|
2 | BANKSEL LCD_PORT ;bank0 -> clrf BSR (bank select register)
|
3 | clrf LCD_PORT ;Init PORTA
|
4 | BANKSEL LCD_LAT ;bank2
|
5 | clrf LCD_LAT ;clear Data Latch
|
6 | BANKSEL LCD_TRIS ;bank1
|
7 | movlw b'00001000' ;b3 inp. other output
|
8 | movwf LCD_TRIS ;set datadirection register
|
9 | BANKSEL ANSELA ;bank3
|
10 | movlw b'00001000' ;b3 analog inp. other digital i/O
|
11 | movwf ANSELA
|
12 | ;
|
13 | ;--INTERNAL OSCILLATOR S.85 default 500kHz after reset
|
14 | BANKSEL OSCCON ;bank1
|
15 | movlw b'01101010' ;4xPLL OFF, 4MHz, Int.Osc
|
16 | movwf OSCCON ;dont forget FOSC (Labels & Constants)
|
17 | clrf OSCTUNE ;Osc. runs at factory-calib. freq.
|
18 | ; OSCSTAT ;Osc status register (flags önly)
|
19 | ;--CAPACITIVE SENSING MODULE "CSM" S.315
|
20 | ; ===============================
|
21 | ; ok • Set the corresponding TRIS bit
|
22 | ; ok • Set the corresponding ANSEL bit
|
23 | ; ok • Select the appropriate CPS pin -> CPSCON1,CPSCH<3:0> CPS3=RA3
|
24 | ; ok • Run the software algorithm
|
25 | ;
|
26 | ; ok • CS Os current settings CPSCON0,CPSRNG1:0
|
27 | ; ok • clock TMR0 || or TMR1 by the CS Osc
|
28 | ; ok • Software loop or Timer as fixd timebase
|
29 | ; ok TMR0 • Set the T0XCS bit 0 of the CPSCON0 register
|
30 | ; ok • Clear the TMR0CS bit of the OPTION register
|
31 | ; !!! Widerspruch im Blockschaltbild TMR0CS = 1!
|
32 | ; beide Möglichkeiten funktionieren nicht
|
33 | ; -- TMR1 • Set T1CON,TMR1CS1:0 ="11"
|
34 | ; -- • clock TMR1 by the CS Osc
|
35 | ;
|
36 | ; Datenblatt S. 316, Blockschaltbild
|
37 | ; CPS0 : CPS11 CPSCON1 RA3 = CPS3
|
38 | ; CAPSOSC intern
|
39 | ; T0XCS = 1 CPSCON0
|
40 | ; TMR0CS = 1 OPTION_REG
|
41 | ; TMR0 intern
|
42 | ; TMR0IF 0-1 TMR0 255->0
|
43 | ;
|
44 | BANKSEL OPTION_REG ;S.176
|
45 | ; TMR0 clock source is CAPSOSC, no Prescaler
|
46 | clrf OPTION_REG
|
47 | bsf OPTION_REG,TMR0CS ;b5=1 TMR0 Clk source CAPSOSC
|
48 | bsf OPTION_REG,PSA ;b3=1 Presc. not assigned to TMR0
|
49 | ;
|
50 | BANKSEL CPSCON0 ;bank0 S.318
|
51 | bsf CPSCON0,CPSON ;b7=1 CSM is enabled
|
52 | bsf CPSCON0,CPSRNG1 ;b3:2=11 high range I=18µA
|
53 | bsf CPSCON0,CPSRNG0 ; 01 low range, 00 CAPSOSC off
|
54 | ; CPSCON0,CPSOUT ;b1=1/0, flag Curr. flowing out/in the pin)
|
55 | bsf CPSCON0,T0XCS ;b0=1 and TMR0CS=1 TMR0 clocked by CAPSOSC
|
56 | ;
|
57 | BANKSEL CPSCON1 ;S.319
|
58 | movlw b'00000011' ;b3:0 0011 channel 3, (CPS3) RA3
|
59 | movwf CPSCON1 ;vgl. S. 11
|