Hallo
ich habe ein Schaltung nach gebaut und leider funktioniert sie nicht.
Nach die Versuchen und Messungen habe ich den verdacht das der 16F84A nicht arbeitet. Wie kann ich das Überprüfen ?

Die Schaltung ist von folgender Seite:
http://www.transmic.net/gb1684.htm

Leider nur in Englisch oder Französisch bzw. Google-Translator Deutsch.

Wenn ich aber alles richtig verstanden habe, müsste PIN13 RB7 eine Led (D1) einschalten wenn an PIN 2 RA3 ein Signal anliegt.

Könnte mir das einer an Hand des Programmes bestätigen, diese geschieht nämlich nicht und wie könnte ich dann den 16f84 überprüfen ob der noch in Ordnung ist.

Ein 4mHz Quarz ist verbaut, Versorgungsspannung und so liegt an.

  • ;================================================= =========================
    Title "Bike Advance"
    ; http://www.perso.wanadoo.fr/transmic/
    ; 05 03 04 Version 4.23Beta for 16f84 Thierry.P
    ; -------------------------------------------------------------------------
    ; Adaptation of the program Ign.txt "Auto Advance" from A. Nixon
    ; Title "Auto Advance" for 16c54
    ; 24 08 94 Version 1.0 A. Nixon
    ;================================================= =========================

    ;================================================= =========================
    ;
    ; PIC 16F84 wiring
    ;
    ;================================================= =========================

    ;
    ; RA2 1+--O--+18 RA1
    ; pickup36°-----------> RA3 2| |17 RA0
    ; RA4 3| |16 Osc ------ 4MHz
    ; +5V--+----R---------> MCLR 4| |15 Osc ------ Quartz
    ; Ground--------------- Vss 5| |14 Vcc ------ +5Vdc
    ; Thyristor <------- RB0 6| |13 RB7 ------>PickupLED
    ; LEDrpmLimit <------- RB1 7| |12 RB6
    ; ReverseOutput<------- RB2 8| |11 RB5
    ; RB3 9+-----+10 RB4

    ;================================================= =========================
    ;
    ; Directives
    ;
    ;================================================= =========================
    list p=16f84a ; processor type
    ;
    __config B'11111111110010'
    ; No code protect, PWRT on, no watchdog, Quartz 4to20Mhz
    ;
    ; Page 0: 0-FF page1: 100-1FF page2: 200-2FF page3: 300-3FF
    ;================================================= =========================
    ;
    ; Register Definitions
    ;
    ;================================================= =========================

    W EQU H'0000'
    F EQU H'0001'

    ;----- Register Files------------------------------------------------------

    INDF EQU H'0000'
    TMR0 EQU H'0001'
    PCL EQU H'0002'
    STATUS EQU H'0003'
    FSR EQU H'0004'
    PORTA EQU H'0005'
    PORTB EQU H'0006'
    EEDATA EQU H'0008'
    EEADR EQU H'0009'
    PCLATH EQU H'000A'
    INTCON EQU H'000B'

    OPTION_REG EQU H'0081'
    TRISA EQU H'0085'
    TRISB EQU H'0086'
    EECON1 EQU H'0088'
    EECON2 EQU H'0089'

    ;----- STATUS Bits --------------------------------------------------------

    IRP EQU H'0007'
    RP1 EQU H'0006'
    RP0 EQU H'0005'
    NOT_TO EQU H'0004'
    NOT_PD EQU H'0003'
    Z EQU H'0002'
    DC EQU H'0001'
    C EQU H'0000'

    ;----- INTCON Bits --------------------------------------------------------

    GIE EQU H'0007'
    EEIE EQU H'0006'
    T0IE EQU H'0005'
    INTE EQU H'0004'
    RBIE EQU H'0003'
    T0IF EQU H'0002'
    INTF EQU H'0001'
    RBIF EQU H'0000'

    ;----- OPTION Bits --------------------------------------------------------

    NOT_RBPU EQU H'0007'
    INTEDG EQU H'0006'
    T0CS EQU H'0005'
    T0SE EQU H'0004'
    PSA EQU H'0003'
    PS2 EQU H'0002'
    PS1 EQU H'0001'
    PS0 EQU H'0000'

    ;================================================= =========================
    ;
    ; Define
    ;
    ;================================================= =========================

    #DEFINE rotor PORTA,3 ; [pin2]= sensor input
    #DEFINE coil PORTB,0 ; [pin6]= output to coil
    #DEFINE revcoil PORTB,2 ; [pin8]= reverse output to coil
    #DEFINE rpmmax PORTB,1 ; [pin7]= Min and Max RPM led
    #DEFINE led PORTB,7 ; [pin13]= pickup led

    ;================================================= =========================
    ;
    ; RAM Definition
    ;
    ;================================================= =========================

    rpmhi equ 0Ch ; RPM counter register high
    rpmlo equ 0Dh ; RPM counter register low
    dwell equ 0Eh ; dwell time counter
    rtdset equ 0Fh ; retard value holding register
    math equ 11h ; calculation register
    coilflg equ 12h ; coil status
    spkflg equ 13h ; flag after one spark
    rotflg equ 14h ; rotor sense flag
    retard equ 15h ; new retard value

    ;================================================= =========================
    ;
    ; Main Program
    ;
    ;================================================= =========================


    org 0 ; start adress 0
    start bsf STATUS,RP0 ; go to bank 1
    movlw H'FF' ; set all portA..
    movlw TRISA ; ..as inputs
    movlw H'00' ; set all portB..
    movwf TRISB ; ..as outputs
    ;
    movlw b'11000001' ; no pull-up,rising edge int,internal timer,1:4
    movwf OPTION_REG
    bcf STATUS,RP0 ; come back into bank 0
    ;
    clrw ; clear all variables
    clrf PORTA ; clear variables
    clrf PORTB
    clrf math
    clrf rpmlo
    clrf coilflg
    movlw 0xff ; rpmhi = FF initially
    movwf rpmhi
    movwf spkflg ; no spark until pickup is high
    movwf rotflg ; and no spark loop if pickup stay up
    movwf retard ; retard value = 25ms initially
    ;
    ;
    ; 100uS loop time
    ; 4MHz clock / 4 = 1MHz instruction cycle
    ; cycle time = 1/1MHz = 100uS
    ; 100uS/100uS = 100 cycles
    ; prescaler set to divide by 4
    ; preset TMR0 = 231, when = 0 = 100uS
    ; 231 to 255 = 25 x 4(prescaler) = 100
    ;
    movlw .231 ;movlw .206 for a 8MHz clock
    movwf TMR0
    ;
    ;
    mnloop movf TMR0,W
    btfss STATUS,Z ; is TMR0=0 ?
    goto mnloop ; no, main delay loop
    ;
    movlw .231 ; yes, re-preset TMR0 (240max)
    movwf TMR0
    ;
    incf rpmlo,F ; increment rpmlo
    btfsc STATUS,Z ; is rpmlo = 0 ?
    incf rpmhi,F ; yes, increment rpmhi
    ;
    ; if rpm count > 1400h, 5120 x 100us=0.5 Secs, then it is assumed that the
    ; motor has stopped. Reinitialize system.
    movlw 0x14
    subwf rpmhi,W
    btfsc STATUS,Z ; rpmhi - 14 = 0 ?
    goto start ; yes
    ;

    rotchk btfss rotor ; + is rotor high or low?
    ;btfsc rotor ; (- detect pickup low)
    goto rnowlw ; low
    ;
    movf rotflg,W ; high, is it flagged high also? rotflg=FF?
    btfss STATUS,Z
    goto coilck ; yes
    ;
    movlw 0xff ; no
    movwf rotflg ; flag rotor as up
    bsf led ; turn ignition pickup led on
    clrf spkflg ; reset flag for one spark
    goto rpmcalc ; calculate RPM
    ;

    rnowlw movf rotflg,W ; is it flagged low already ? rotflg=0?
    btfsc STATUS,Z
    goto coilck ; yes, wasn't flagged high
    ;

    dolow bcf led ; no, turn ignition pickup led off
    clrf rotflg ; flag rotor as down
    goto mnloop
    ;

    decret decf retard,F ; no, decrement retard then wait
    goto mnloop
    ;

    coilck movf coilflg,W ; is coil flagged high? coilflg=FF?
    btfss STATUS,Z
    goto upcoil ; yes, then decrement dwell count
    movf retard,W ; is retard = 0 ?
    btfss STATUS,Z
    goto decret ; no, then decrement retard
    ;
    movf spkflg,W ; yes, a spark have been done? spkflg=FF?
    btfss STATUS,Z
    goto mnloop ; yes, no more spark
    ;
    bsf coil ; no, go on for the first spark
    bcf revcoil
    movlw 0xff ; set flag for high coil
    movwf coilflg
    movwf spkflg ; set flag for one spark

    ; ****************** YOU CAN MODIFY THE DWELL VALUE BELLOW ********
    movlw .10 ; 10 X 100uS = 1mS
    movwf dwell ; set dwell time
    ;
    goto mnloop
    ;

    upcoil ; if dwell # 0 then dwell - 1
    ; if dwell now = 0, turn on coil
    ;
    decfsz dwell,F ; dwell = dwell - 1
    goto mnloop ; dwell <> 0, wait
    bcf coil ; dwell = 0, turn coil off
    bsf revcoil ; dwell = 0, turn revcoil on
    clrf coilflg ; set flag for low coil
    goto mnloop
    ;

    rpmcalc ; engine RPM <= 1000 at maximum retard, = 60ms
    ;
    ; 60mS = 600 X 100us loops, = 258Ch
    ; ( 1000RPM for a 1cyl - 4stroke with one spark loose )
    ; ( 1000RPM for a 1cyl - 2stroke )
    ; ( 500RPM for a 4cyl - 4stroke = 16Hz )
    ;
    ; engine RPM >= 8000 at maximum advance, = 7.5mS
    ; 7.5mS = 75 X 100uS loops, = 4Bh
    ; ( 8000RPM for a 1cyl - 4stroke with one spark loose )
    ; ( 8000RPM for a 1cyl - 2stroke )
    ; ( 4000RPM for a 4cyl - 4stroke = 133Hz )
    ;
    ; this routine determines whether the engine RPM
    ; value is below 75 loop counts - max advance, or above
    ; 600 loop counts - max retard, or some where in between.
    ;
    ;
    ; high RPM: ; > 8000RPM
    ;
    movf rpmhi,W
    btfss STATUS,Z ; is rpmhi = 0?
    goto bigfv ; no
    ;
    movf rpmlo,W
    xorlw 0x4B ; yes, is rpmlo = 4Bh ?
    btfsc STATUS,Z
    goto maxadv ; yes, do max advance
    ;
    movlw 0x4B
    subwf rpmlo,W ; no, is rpmlo < 4Bh ?
    btfss STATUS,C
    goto maxadv ; yes, do max advance
    ;
    ; medium RPM:
    goto caladv ; no, calculate new advance
    ;
    ;
    ; low RPM: ; < 1000RPM
    bigfv movf rpmhi,W
    xorlw .2 ; is rpmhi = 2 ?
    btfsc STATUS,Z
    goto resfv ; yes, see if rpmlo = 58h
    ;
    movlw .2
    subwf rpmhi,W ; no, is high byte > 2 ?
    btfsc STATUS,C
    goto maxret ; yes, do max retard
    ;
    goto caladv ; no, calculate new advance
    ;
    resfv movf rpmlo,W
    xorlw 0x58 ; rpmhi = 2, does rpmlo = 58h ?
    btfsc STATUS,Z
    goto maxret ; yes, do max retard
    ;
    movlw 0x58
    subwf rpmlo,W ; no, is rpmlo > 58h ?
    btfsc STATUS,C
    goto maxret ; yes, do max retard
    ;
    ;
    ; the formula to get the data stored in the map is as follows
    ;
    ; rpmhi/lo count - 74
    ; 131 - ---------------------------
    ; 4
    ;
    caladv movlw d'74' ; rpmhi/lo - 74
    subwf rpmlo,F ; rpmlo = rpmlo - 74
    btfss STATUS,C
    decf rpmhi,F
    ;
    ; divide result by 4
    ;
    bcf STATUS,C
    rrf rpmhi,F
    rrf rpmlo,F ; / 2
    ;
    bcf STATUS,C
    rrf rpmhi,F
    rrf rpmlo,F ; / 4
    ;
    movlw .131 ; 131 entries in map list
    movwf math
    ;
    movf rpmlo,W
    subwf math,W ; W = 131 - result
    ;
    bcf PCLATH,0 ; be sure to go h'200'
    bsf PCLATH,1 ; where is the map.
    call map ; read map
    movwf rtdset ; come back with new retard value
    ;
    rpmset clrf rpmhi ; clear RPM counters
    clrf rpmlo
    movf rtdset,W ; transfert advance value
    movwf retard
    goto mnloop
    ;
    maxret movlw 0x32
    movwf rtdset ; retard value = 32h (5ms) 258=600=16hz
    bcf rpmmax ; turn off maxrpm led
    goto rpmset
    ;
    maxadv clrf rtdset ; retard value = 0ms 4B=75=124hz
    bsf rpmmax ; turn on maxrpm led
    goto rpmset
    ;
    map org h'200' ; store map at 200h
    addwf PCL,1 ; add W + PCL
    ; *********** INSERT YOUR OWN VALUES HERE *******************
    retlw 31h ;4,9ms 1000rpm
    retlw 30h ;4,8ms 1016rpm
    retlw 2Fh ;4,7ms 1023rpm
    retlw 2Fh ;4,7ms 1030rpm
    retlw 2Eh ;4,6ms 1038rpm
    retlw 2Dh ;4,5ms 1045rpm
    retlw 2Dh ;4,5ms 1052rpm
    retlw 2Ch ;4,4ms 1060rpm
    retlw 2Bh ;4,3ms 1067rpm
    retlw 2Ah ;4,2ms 1075rpm
    retlw 2Ah ;4,2ms 1083rpm
    retlw 29h ;4,1ms 1090rpm
    retlw 28h ;4ms 1098rpm
    retlw 28h ;4ms 1107rpm
    retlw 27h ;3,9ms 1115rpm
    retlw 26h ;3,8ms 1123rpm
    retlw 26h ;3,8ms 1132rpm
    retlw 25h ;3,7ms 1140rpm
    retlw 24h ;3,6ms 1149rpm
    retlw 24h ;3,6ms 1158rpm
    retlw 23h ;3,5ms 1167rpm
    retlw 22h ;3,4ms 1176rpm
    retlw 22h ;3,4ms 1185rpm
    retlw 21h ;3,3ms 1195rpm
    retlw 20h ;3,2ms 1204rpm
    retlw 20h ;3,2ms 1214rpm
    retlw 1Fh ;3,1ms 1224rpm
    retlw 1Eh ;3ms 1234rpm
    retlw 1Eh ;3ms 1244rpm
    retlw 1Dh ;2,9ms 1255rpm
    retlw 1Dh ;2,9ms 1265rpm
    retlw 1Ch ;2,8ms 1276rpm
    retlw 1Ch ;2,8ms 1287rpm
    retlw 1Bh ;2,7ms 1298rpm
    retlw 1Ah ;2,6ms 1310rpm
    retlw 1Ah ;2,6ms 1321rpm
    retlw 19h ;2,5ms 1333rpm
    retlw 19h ;2,5ms 1345rpm
    retlw 18h ;2,4ms 1357rpm
    retlw 18h ;2,4ms 1369rpm
    retlw 17h ;2,3ms 1382rpm
    retlw 17h ;2,3ms 1395rpm
    retlw 16h ;2,2ms 1408rpm
    retlw 16h ;2,2ms 1421rpm
    retlw 15h ;2,1ms 1435rpm
    retlw 14h ;2ms 1449rpm
    retlw 14h ;2ms 1463rpm
    retlw 14h ;2ms 1477rpm
    retlw 13h ;1,9ms 1492rpm
    retlw 13h ;1,9ms 1507rpm
    retlw 12h ;1,8ms 1522rpm
    retlw 12h ;1,8ms 1538rpm
    retlw 11h ;1,7ms 1554rpm
    retlw 11h ;1,7ms 1570rpm
    retlw 10h ;1,6ms 1587rpm
    retlw 10h ;1,6ms 1604rpm
    retlw 0Fh ;1,5ms 1621rpm
    retlw 0Fh ;1,5ms 1639rpm
    retlw 0Eh ;1,4ms 1657rpm
    retlw 0Eh ;1,4ms 1675rpm
    retlw 0Eh ;1,4ms 1694rpm
    retlw 0Dh ;1,3ms 1714rpm
    retlw 0Dh ;1,3ms 1734rpm
    retlw 0Ch ;1,2ms 1754rpm
    retlw 0Ch ;1,2ms 1775rpm
    retlw 0Ch ;1,2ms 1796rpm
    retlw 0Bh ;1,1ms 1818rpm
    retlw 0Bh ;1,1ms 1840rpm
    retlw 0Ah ;1ms 1863rpm
    retlw 0Ah ;1ms 1886rpm
    retlw 0Ah ;1ms 1910rpm
    retlw 9h ;1ms 1935rpm
    retlw 9h ;1ms 1960rpm
    retlw 9h ;0,9ms 1986rpm
    retlw 8h ;0,9ms 2013rpm
    retlw 8h ;0,9ms 2040rpm
    retlw 8h ;0,8ms 2068rpm
    retlw 7h ;0,8ms 2097rpm
    retlw 7h ;0,8ms 2127rpm
    retlw 7h ;0,7ms 2158rpm
    retlw 6h ;0,7ms 2189rpm
    retlw 6h ;0,7ms 2222rpm
    retlw 6h ;0,6ms 2255rpm
    retlw 6h ;0,6ms 2290rpm
    retlw 5h ;0,6ms 2325rpm
    retlw 5h ;0,6ms 2362rpm
    retlw 5h ;0,5ms 2400rpm
    retlw 4h ;0,5ms 2439rpm
    retlw 4h ;0,5ms 2479rpm
    retlw 4h ;0,4ms 2521rpm
    retlw 4h ;0,4ms 2564rpm
    retlw 3h ;0,4ms 2608rpm
    retlw 3h ;0,4ms 2654rpm
    retlw 3h ;0,4ms 2702rpm
    retlw 3h ;0,3ms 2752rpm
    retlw 3h ;0,3ms 2803rpm
    retlw 2h ;0,3ms 2857rpm
    retlw 2h ;0,3ms 2912rpm
    retlw 2h ;0,2ms 2970rpm
    retlw 2h ;0,2ms 3030rpm
    retlw 2h ;0,2ms 3092rpm
    retlw 1h ;0,2ms 3157rpm
    retlw 1h ;0,2ms 3225rpm
    retlw 1h ;0,2ms 3296rpm
    retlw 1h ;0,1ms 3370rpm
    retlw 1h ;0,1ms 3448rpm
    retlw 1h ;0,1ms 3529rpm
    retlw 1h ;0,1ms 3614rpm
    retlw 1h ;0,1ms 3703rpm
    retlw 1h ;0,1ms 3797rpm
    retlw 1h ;0,1ms 3896rpm
    retlw 0h ;0ms 4000rpm
    retlw 0h ;0ms 4109rpm
    retlw 0h ;0ms 4225rpm
    retlw 0h ;0ms 4347rpm
    retlw 85h ;13,3ms 4477rpm extra advance
    retlw 80h ;12,8ms 4615rpm
    retlw 7Bh ;12,3ms 4761rpm
    retlw 77h ;11,9ms 4918rpm
    retlw 72h ;11,4ms 5084rpm
    retlw 6Fh ;11,1ms 5263rpm
    retlw 69h ;10,5ms 5454rpm
    retlw 65h ;10,1ms 5660rpm
    retlw 61h ;9,7ms 5882rpm
    retlw 56h ;8,9ms 6122rpm
    retlw 51h ;8,1ms 6382rpm
    retlw 4Dh ;7,7ms 6666rpm
    retlw 4Bh ;7,5ms 6976rpm
    retlw 49h ;7,3ms 7317rpm
    retlw 47h ;7,1ms 7692rpm
    retlw 31h ;4,9ms
    ; *********** END OF YOUR OWN VALUES ******************************
    retlw 31h ; in case of overlap
    ; line559
    ;
    ; reset vector
    ;
    ;
    org 300h ; if the program is loose,
    ;
    ;
    ;
    goto start ; It goes back home.
    ;
    ;
    ;
    end