Forum: Mikrocontroller und Digitale Elektronik PIC16F1827 Capacitive Sensing Module Assembler


von Ottmar K. (wil1)


Angehängte Dateien:

Lesenswert?

Hallo,
seit mehreren Tagen versuche ich das Capacitive Sensing Modul (CSM) des 
PIC 16F1827 erfolglos in Gang zu bringen. Ich meine exakt nach der 
Beschreibung im Datenblatt vorgegangen zu sein. Den Code habe ich 
mehrfach kontrolliert. Auch habe ich ergebnislos einen neuen 16F1827 
verwendet.
Auch wenn ich alle Portpins (auch PORTB) als Inputs aktiviere kann ich 
mit dem Oszilloskop an keinem Pin irgendwelche Impulse erkennen.
Im Code ist PORTA,RA3 als Input CSP3 (channel 3) für das CSM 
konfiguriert.

Würde sich bitte jemand die Mühe machen meinen Code mal anzusehen, wo 
evtl. der Fehler steckt? Die im Code angeführten Seitenzahlen  beziehen 
sich auf das Datenblatt des 16F1827 (DS41391D).

Vorsorglich habe ich mein gesamtes ASM-File (erstellt mit MPLAB 8,92) 
als Anlage beigefügt.

mit bestem Dank schon im Voraus

mfG Ottmar

Auszug aus dem Gesamtcode:
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

von Ottmar K. (wil1)


Lesenswert?

Hallo,
ich melde mich nochmals zu Wort: kann es sein, dass niemand eine Antwort 
auf meine Frage weiß?

hoffe weiterhin auf Antwort
mfG Ottmar

von Ottmar K. (wil1)


Lesenswert?

Hallo
Problem ist gelöst, das CSM-Modul funktioniert nun einwandfrei
mfg Ottmar

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.