PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : 16f876 und Parsic



grischan
04.04.2006, 14:10
Hallo

ich habe mit parsic schon mit dem 16c84 erfolge gehapptdieser pic reicht mit aber nicht.
Somit die frage, hat jemand schon erfahrungen mit dem pic 16f876 und dem programm Parsic http://www.parsic.de/ gemacht. Es läuft nähmlich gar nichts mit diesem pic, obwohl er von diesem programm unterstützt wird.

erfahrungen an andere 16f87x könnten auch weiter helfen.

es geht um speziell dieses Programm in Parsic nur für den 16f876 (Dateianhang)

mit Parsic erstellter Programmcode

PROCESSOR 16F84

INCLUDE P16F84.INC

RADIX DEC


__IDLOCS H'0000'

__CONFIG _CP_OFF & _PWRTE_ON & _WDT_ON & _XT_OSC

; Diverses

ZERO EQU Z ; ZERO-Flag
CARRY EQU C ; CARRY-Flag


; Variable

SYS_WSAV = 12 ; located in Bank 0, 1
SYS_SSAV = 13 ; located in Bank 0, 1
TR1 = 14 ; located in Bank 0, 1
TR1_HI = 15 ; located in Bank 0, 1
S4 = 16 ; located in Bank 0, 1
ZV1 = 17 ; located in Bank 0, 1
ZV1_HI = 18 ; located in Bank 0, 1
ZV1_FD = 19 ; located in Bank 0, 1
SYS_TMP1 = 20 ; located in Bank 0, 1
S0 = 21 ; located in Bank 0, 1
S3 = 22 ; located in Bank 0, 1
S1 = 23 ; located in Bank 0, 1
S2 = 24 ; located in Bank 0, 1
ZV2 = 25 ; located in Bank 0, 1
ZV2_FD = 26 ; located in Bank 0, 1
RAM = 27 ; located in Bank 0, 1

ERRORLEVEL -302 ; disable warning (Bankswitching)
ERRORLEVEL -306 ; disable warning (Pageswitching)

;****************************************
;Programmanfang
;****************************************

ORG 0

CLRF STATUS ; switch to RAM-Bank 0
MOVLW HIGH SYS_INIT ; set ROM-Bank
MOVWF PCLATH
GOTO SYS_INIT

;****************************************
;Interrupt-Adress
;****************************************

MOVWF SYS_WSAV ; Register sichern
SWAPF STATUS,W
CLRF STATUS ; BANK0
MOVWF SYS_SSAV

INCFSZ TR1,F
GOTO SYS_INT_LABEL_0
INCF TR1_HI,F

SYS_INT_LABEL_0
BCF INTCON,T0IF ; Interrupt quitieren

EXITINT

SWAPF SYS_SSAV,W ; Register zurück
MOVWF STATUS
SWAPF SYS_WSAV,F
SWAPF SYS_WSAV,W

RETFIE ; RETurn From Interrupt and Enable GIE


;****************************************
; Subroutines
;****************************************


;****************************************
; Tables
;****************************************


;****************************************
;Initialisierung
;****************************************


SYS_INIT

MOVLW B'00100000'
MOVWF INTCON

; Ausgangs-Pegel setzen, bevor die Richtung gesetzt wird

BCF STATUS,RP0 ; Bank 0
MOVLW B'00000000'
MOVWF PORTA

MOVLW B'00000000'
MOVWF PORTB

MOVLW 15
BSF STATUS,RP0 ; Bank 1
MOVWF OPTION_REG


; Richtung setzen

MOVLW B'11111111'
MOVWF TRISA

MOVLW B'00000000'
MOVWF TRISB

; init var

CLRF SYS_WSAV
CLRF SYS_SSAV
CLRF TR1
CLRF TR1_HI
CLRF S4
CLRF ZV1
CLRF ZV1_HI
CLRF ZV1_FD
CLRF SYS_TMP1
CLRF S0
CLRF S3
CLRF S1
CLRF S2
CLRF ZV2
CLRF ZV2_FD

BCF STATUS,RP0 ; Bank 0
CLRF TMR0
BCF INTCON,T0IF
BSF INTCON,GIE ; Interrupt freigeben

;**********************************
;******* Haupt-Programm ***********
;**********************************

MAIN

CLRWDT

;************************************************* **
; Timer -> TR1
;************************************************* **

MOVLW 0 ; Test auf >=
SUBWF TR1_HI,W ;F-W -> W
BTFSS STATUS,CARRY
GOTO LABEL_TR1_ENDE
MOVLW 195
SUBWF TR1,W ;F-W -> W
BTFSS STATUS,CARRY
GOTO LABEL_TR1_ENDE

LABEL_TR1_RESET
CLRF TR1 ; reset time
CLRF TR1_HI ; reset time

LABEL_TR1_SET ; toggel output
BTFSC S4,0
GOTO LABEL_TR1_CLR
BSF S4,0
GOTO LABEL_TR1_ENDE
LABEL_TR1_CLR
BCF S4,0
LABEL_TR1_ENDE

;************************************************* **
; Zähler -> ZV1
;************************************************* **

BTFSS S4,1 ; Reset ?
GOTO LABEL_ZV1_COUNT
CLRF ZV1
CLRF ZV1_HI
GOTO LABEL_ZV1_SETOUT

LABEL_ZV1_COUNT

; Test auf positive Flanke

BTFSS S4,0
GOTO LABEL_ZV1_SETFD
BTFSC ZV1_FD,0
GOTO LABEL_ZV1_SETFD

BSF ZV1_FD,0


BTFSC S4,2 ; Vorwärts oder Rückwärts ?
GOTO LABEL_ZV1_BACKWARD

INCFSZ ZV1,F
GOTO LABEL_ZV1_SETOUT
INCF ZV1_HI,F
GOTO LABEL_ZV1_SETOUT

LABEL_ZV1_BACKWARD
DECF ZV1,F
INCFSZ ZV1,W
GOTO LABEL_ZV1_SETOUT
DECF ZV1_HI,F

LABEL_ZV1_SETOUT


LABEL_ZV1_SETFD

; Test auf negative Flanke

BTFSC S4,0
GOTO LABEL_ZV1_EXIT
BCF ZV1_FD,0

LABEL_ZV1_EXIT

;************************************************* **
; Schmitt-Trigger 8-Bit -> ST1
;************************************************* **

BTFSC S4,1 ; Ausgang gesetzt ?
GOTO LABEL_ST1_MH ; dann mit Hysterese ?

MOVLW 8
GOTO LABEL_ST1_TEST

LABEL_ST1_MH

MOVLW 8
LABEL_ST1_TEST

SUBWF ZV1,W
BTFSS STATUS,CARRY
GOTO LABEL_ST1_RESET

BSF S4,1 ; if greater or equal
GOTO LABEL_ST1_ENDE

LABEL_ST1_RESET
BCF S4,1 ; if less
LABEL_ST1_ENDE

;************************************************* **
; Unterprogramm PRG1 aufrufen
;************************************************* **

MOVFW ZV1

CALL PRG1

MOVWF S0

;************************************************* **
; Multiplexer -> MX1
;************************************************* **

CLRF SYS_TMP1
MOVFW ZV2
BTFSS STATUS,ZERO
GOTO LABEL_MX1_CHECKCONTROL1

MOVFW S0
MOVWF S3
GOTO LABEL_MX1_END

LABEL_MX1_CHECKCONTROL1
INCF SYS_TMP1,F
MOVFW ZV2
SUBWF SYS_TMP1,W
BTFSS STATUS,ZERO
GOTO LABEL_MX1_CHECKCONTROL2

MOVFW S1
MOVWF S3
GOTO LABEL_MX1_END

LABEL_MX1_CHECKCONTROL2
INCF SYS_TMP1,F
MOVFW ZV2
SUBWF SYS_TMP1,W
BTFSS STATUS,ZERO
GOTO LABEL_MX1_CHECKCONTROL3

MOVFW S2
MOVWF S3
GOTO LABEL_MX1_END

LABEL_MX1_CHECKCONTROL3

LABEL_MX1_END

;************************************************* **
; Unterprogramm PRG2 aufrufen
;************************************************* **

MOVFW ZV1

CALL PRG2

MOVWF S1

;************************************************* **
; GND
;************************************************* **

BCF S4,2 ; immer Low

;************************************************* **
; UND - Gatter -> UG1
;************************************************* **

LABEL_UG1_1
BTFSS S4,3
GOTO LABEL_UG1_FALSE
LABEL_UG1_2
BTFSS S4,4
GOTO LABEL_UG1_FALSE

LABEL_UG1_TRUE
BSF S4,5
GOTO LABEL_UG1_ENDE
LABEL_UG1_FALSE
BCF S4,5
LABEL_UG1_ENDE
;************************************************* **
; Unterprogramm PRG3 aufrufen
;************************************************* **

MOVFW ZV1

CALL PRG3

MOVWF S2

;************************************************* **
; Verteiler -> BV1
;************************************************* **

BTFSC S3,0
GOTO LABEL_BV1_0
BCF STATUS,RP0 ; Bank 0
BCF PORTB,0
GOTO LABEL_BV1_0_END
LABEL_BV1_0
BCF STATUS,RP0 ; Bank 0
BSF PORTB,0
LABEL_BV1_0_END

;**********************************************

BTFSC S3,1
GOTO LABEL_BV1_1
BCF PORTB,1
GOTO LABEL_BV1_1_END
LABEL_BV1_1
BSF PORTB,1
LABEL_BV1_1_END

;**********************************************

BTFSC S3,2
GOTO LABEL_BV1_2
BCF PORTB,2
GOTO LABEL_BV1_2_END
LABEL_BV1_2
BSF PORTB,2
LABEL_BV1_2_END

;**********************************************

BTFSC S3,3
GOTO LABEL_BV1_3
BCF PORTB,3
GOTO LABEL_BV1_3_END
LABEL_BV1_3
BSF PORTB,3
LABEL_BV1_3_END

;**********************************************

BTFSC S3,4
GOTO LABEL_BV1_4
BCF PORTB,4
GOTO LABEL_BV1_4_END
LABEL_BV1_4
BSF PORTB,4
LABEL_BV1_4_END

;**********************************************

BTFSC S3,5
GOTO LABEL_BV1_5
BCF PORTB,5
GOTO LABEL_BV1_5_END
LABEL_BV1_5
BSF PORTB,5
LABEL_BV1_5_END

;**********************************************

BTFSC S3,6
GOTO LABEL_BV1_6
BCF PORTB,6
GOTO LABEL_BV1_6_END
LABEL_BV1_6
BSF PORTB,6
LABEL_BV1_6_END

;**********************************************

BTFSC S3,7
GOTO LABEL_BV1_7
BCF PORTB,7
GOTO LABEL_BV1_7_END
LABEL_BV1_7
BSF PORTB,7
LABEL_BV1_7_END

;**********************************************


;************************************************* **
; Zähler -> ZV2
;************************************************* **

BTFSS S4,5 ; Reset ?
GOTO LABEL_ZV2_COUNT
CLRF ZV2
GOTO LABEL_ZV2_SETOUT

LABEL_ZV2_COUNT

; Test auf positive Flanke

BCF STATUS,RP0 ; Bank 0
BTFSS PORTA,0
GOTO LABEL_ZV2_SETFD
BTFSC ZV2_FD,0
GOTO LABEL_ZV2_SETFD

BSF ZV2_FD,0


BTFSC S4,6 ; Vorwärts oder Rückwärts ?
GOTO LABEL_ZV2_BACKWARD

INCF ZV2,F
GOTO LABEL_ZV2_SETOUT

LABEL_ZV2_BACKWARD
DECF ZV2,F

LABEL_ZV2_SETOUT

; Output Q0

BTFSS ZV2,0
GOTO LABEL_ZV2_SETOUT0
BSF S4,3
GOTO LABEL_ZV2_SETOUT0_END
LABEL_ZV2_SETOUT0
BCF S4,3
LABEL_ZV2_SETOUT0_END

; Output Q1

BTFSS ZV2,1
GOTO LABEL_ZV2_SETOUT1
BSF S4,4
GOTO LABEL_ZV2_SETOUT1_END
LABEL_ZV2_SETOUT1
BCF S4,4
LABEL_ZV2_SETOUT1_END


LABEL_ZV2_SETFD

; Test auf negative Flanke

BCF STATUS,RP0 ; Bank 0
BTFSC PORTA,0
GOTO LABEL_ZV2_EXIT
BCF ZV2_FD,0

LABEL_ZV2_EXIT

;************************************************* **
; GND
;************************************************* **

BCF S4,6 ; immer Low

;****************************************


GOTO MAIN

ORG 1010
;************************************************* **
;Table -> PRG1
;************************************************* **

PRG1

MOVWF SYS_TMP1
MOVLW HIGH PRG1_WERTE
MOVWF PCLATH
MOVFW SYS_TMP1
ADDWF PCL,F

PRG1_WERTE

RETLW 1
RETLW 2
RETLW 4
RETLW 8
RETLW 16
RETLW 32
RETLW 64
RETLW 128
RETLW 128

ORG 996
;************************************************* **
;Table -> PRG2
;************************************************* **

PRG2

MOVWF SYS_TMP1
MOVLW HIGH PRG2_WERTE
MOVWF PCLATH
MOVFW SYS_TMP1
ADDWF PCL,F

PRG2_WERTE

RETLW 129
RETLW 66
RETLW 36
RETLW 24
RETLW 36
RETLW 66
RETLW 129
RETLW 129
RETLW 129

ORG 982
;************************************************* **
;Table -> PRG3
;************************************************* **

PRG3

MOVWF SYS_TMP1
MOVLW HIGH PRG3_WERTE
MOVWF PCLATH
MOVFW SYS_TMP1
ADDWF PCL,F

PRG3_WERTE

RETLW 255
RETLW 127
RETLW 191
RETLW 223
RETLW 239
RETLW 247
RETLW 251
RETLW 253
RETLW 254


END



vielen dank

LazyBee
13.05.2006, 09:36
Hallo,

ich kenne Parsic nicht, aber auf alle Fälle mußt Du anstelle des 16F84 Deinen neuen PIC konfigurieren.

PROCESSOR 16F8876

INCLUDE P16F876.INC


Gruß

LazyBee