Need once your help one please


Results 1 to 7 of 7

Threaded View

  1. #7
    zugvogel1's Avatar
    zugvogel1 Guest


    Did you find this post helpful? Yes | No

    Default the new version

    the new version


    ; **************************************************
    ;Files Assignment
    ; **************************************************
    symbol A_X1 = PORTA.1 ; A_X1 to PORTA.1
    symbol A_X2 = PORTA.0 ; A_X1 to PORTA.0
    symbol A_X3 = PORTA.7 ; A_X1 to PORTA.7
    symbol A_X4 = PORTA.6 ; A_X1 to PORTA.6
    symbol A_X5 = PORTA.5 ; A_X1 to PORTA.5
    symbol A_X6 = PORTA.4 ; A_X1 to PORTA.4
    symbol A_X7 = PORTA.3 ; A_X1 to PORTA.3
    symbol A_X8 = PORTA.2 ; A_X1 to PORTA.2

    bit0 var R_DATEN.0 ;ist bit0 von R_DATEN
    bit1 var R_DATEN.1 ;ist bit1 von R_DATEN
    bit2 var R_DATEN.2 ;ist bit2 von R_DATEN
    bit3 var R_DATEN.3 ;ist bit3 von R_DATEN
    bit4 var R_DATEN.4 ;ist bit4 von R_DATEN
    bit5 var R_DATEN.5 ;ist bit5 von R_DATEN
    bit6 var R_DATEN.6 ;ist bit6 von R_DATEN
    bit7 var R_DATEN.7 ;ist bit7 von R_DATEN

    symbol B_CLK = PORTB.0 ; B_CLK to PORTB.0
    symbol B_OUT = PORTB.1 ; B_OUT to PORTB.1
    symbol B_LED = PORTB.2 ; B_LED to PORTB.2
    symbol B_IN = PORTB.6 ; B_IN to PORTB.6
    symbol B_PS = PORTB.7 ; B_PS to PORTB.7
    symbol F_PS_RDY = PORTB.1 ; F_PS_RDY to PORTB.1

    R_DATEN var BYTE
    R_OLD var BYTE
    R_Flag var BYTE

    ; **************************************************
    ASM

    R_DATEN equ 20h ; fuer Speichern der Daten und Schieben
    R_CNT1 equ 22h ; counter 1
    R_CNT2 equ 23h ; counter 2
    R_FLASH equ 24h ; for flashing LED
    R_OLD equ 25h ; Register for old values
    R_FLAG equ 26h ; Register for flags

    F_PS_RDY equ d'1' ; Ready-Flag

    W_TEMP equ h'40' ; saving W-Register
    STATUS_TEMP equ h'41' ; saving Status-Register

    B_PS equ d'7' ; Port B, PS-Eingang
    B_OUT equ d'1' ;Output ; Port B, Data-OUT
    B_IN equ d'6' ; Port B, Data-IN
    A_LED equ d'2' ;Output ; Port A, LED-Ansteuerung
    B_CLK equ d'0' ; Port B, Clock

    endasm
    ; **************************************************

    goto start

    ; **************************************************
    ; Interupt Service Routine ISR
    ; **************************************************
    @ org 0004h ; Interupt Vector

    ; ----- Saving STATUS and W ----------------------
    @ movwf W_TEMP ; W-Register Retten
    @ swapf STATUS,W ; Status-Reg. -> w
    @ movwf STATUS_TEMP ; Status-Reg. Retten

    ; ----- IR IB0-Change (negative Edge) ------------
    @ btfss INTCON,INTF
    goto ir_2
    @ bcf INTCON,INTF ; clear IR-Flag

    @ btfss R_DATEN,0 ; sofort Ausgabe des
    @ bsf PORTB,B_OUT ; .. Bits #0 von
    @ btfsc R_DATEN,0 ; .. R-Daten an
    @ bcf PORTB,B_OUT ; .. DATA_OUT (invertiert)

    If B_CLK <>1 then
    B_LED =0
    else
    toggle B_LED
    endif

    If B_PS =0 then gosub lesen

    @ btfss PORTB,B_IN ; Bit am Eingang
    @ bsf STATUS,C ; .. DATA-IN zum
    @ btfsc PORTB,B_IN ; .. Nachschieben in
    @ bcf STATUS,C ; .. Schieberegister in C
    @ rrf R_DATEN,F ; Daten nachschieben (invertiert)

    ; ab hier sind die Daten in R_DATEN aktualisiert und fertig für
    ; die nächste pos. Flanke von CLK (#0 kann dann sofort an DATA_OUT
    ; weitergegeben werden).

    ; ----- IR by Timer 0 (idle-state) ------------
    ir_2:
    @ btfss INTCON,T0IF
    goto posret
    @ bcf INTCON,T0IF ; clear IR-Flag

    @ comf PORTA,W
    @ movwf PORTA

    ; ----- Restore STATUS and W ---------------------
    posret:
    @ bcf INTCON,INTF ; clear IR-Flag
    @ swapf STATUS_TEMP,W ; in w-Register
    @ movwf STATUS ; w -> Status
    @ SWAPF W_TEMP,F ; W_TEMP -> W, ohne..
    @ SWAPF W_TEMP,W ; .. Z-Flag zu aendern

    @ retfie

    ; **************************************************
    ; Programm
    ; **************************************************
    @ org 0060h ; Position des Programms

    start:
    ; **************************************************
    ; Konfiguration PORTS
    ; **************************************************
    ; bsf STATUS,RP0 ; -> BANK 1
    ; movlw B'11111111'

    TRISB = %11000001
    TRISA = %11111111
    CMCON =%00000111
    OPTION_REG =%10000111
    T2CON =%01111101
    INTCON =%11110000
    PIE1 =%00000000

    ; **************************************************
    ; Main Loop
    ; **************************************************

    loop:
    CLEARWDT ; Watchdog-Timer loeschen
    if B_PS =1 then goto loop2 ; if PS = 1
    @ btfsc R_FLAG,F_PS_RDY ; and PS_RDY not set
    goto loop
    @ movf R_OLD,W ; .. the reload old values
    @ movwf R_DATEN ;
    @ bsf R_FLAG,F_PS_RDY ; .. set FLAG PS_RDY
    goto loop
    loop2:
    @ bcf R_FLAG,F_PS_RDY ; if PS = LOW reset PS_RDY
    goto loop


    ;*********************************
    ; Routine:lesen
    ;*********************************

    lesen:
    @ clrf R_DATEN
    IF A_X8 =1 then
    Bit0 =0
    Else
    ;Bit0 =1
    @ bsf R_DATEN,0
    endif
    IF A_X7 =1 then
    Bit1 =0
    Else
    ;Bit1 =1
    @ bsf R_DATEN,1
    endif
    IF A_X6 =1 then
    Bit2 =0
    Else
    ;Bit2 =1
    @ bsf R_DATEN,2
    endif
    IF A_X5 =1 then
    Bit3 =0
    Else
    ;Bit3 =1
    @ bsf R_DATEN,3
    endif
    IF A_X4 =1 then
    Bit4 =0
    Else
    ;Bit4 =1
    @ bsf R_DATEN,4
    endif
    IF A_X3 =1 then
    Bit5 =0
    Else
    ;Bit5 =1
    @ bsf R_DATEN,5
    endif
    IF A_X2 =1 then
    Bit6 =0
    Else
    ;Bit6 =1
    @ bsf R_DATEN,6
    endif
    IF A_X1 =1 then
    Bit7 =0
    Else
    ;Bit7 =1
    @ bsf R_DATEN,7
    endif

    @ movf R_DATEN,W
    @ movwf R_OLD

    return

    END
    Last edited by zugvogel1; - 9th February 2005 at 20:38.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts