Need once your help one please


Closed Thread
Results 1 to 7 of 7
  1. #1
    zugvogel1's Avatar
    zugvogel1 Guest

    Question Need once your help one please

    Hello

    Need once your help one please.
    Who can help me at the two following would cut off there I not point as I can write the one pic Basic.
    To Thanks onto all of them in advance.

    ------------------------------------------------------------------------------------
    Btfss R_DATEN,0 ; immediately edition of the
    bsf PORTB,B_OUT ; .. bits #0 of
    btfsc R_DATEN,0 ; .. R daten at
    bcf PORTB,B_OUT ; .. DATA_OUT

    ------------------------------------------------------------------------------------

    btfss PORTB,B_IN ; Bit at the entry
    bsf STATUS,C ; .. DATA-IN to the
    btfsc PORTB,B_IN ; .. To
    bcf STATUS,C ; .. shift register into C
    rrf R_DATEN,F ;To daten () negates
    -----------------------------------------------------------------------------------

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmm i'm not sure of the question but i assume you want a translation from assembly to PICBASIC.

    My assembly language is really primitive but i think this can be the solution.
    Code:
    B_OUT   var PORTB.0 ' B_OUT is assign to PORTB.0
    B_IN    var PORTB.1 ' B_IN is assign to PORTB.1
    R_DATEN var BYTE
    
    ' ---------------------------------------------
    ' Btfss R_DATEN,0 ; immediately edition of the
    ' bsf PORTB,B_OUT ; .. bits #0 of 
    ' btfsc R_DATEN,0 ; .. R daten at 
    ' bcf PORTB,B_OUT ; .. DATA_OUT
    ' ---------------------------------------------
    
    if R_DATEN.0 = 0 then 
       B_OUT=1
    else
       B_OUT=0
    endif
    
    ' ----------------------------------------
    ' btfss PORTB,B_IN ; Bit at the entry
    ' bsf STATUS,C ; .. DATA-IN to the
    ' btfsc PORTB,B_IN ; .. To
    ' bcf STATUS,C ; .. shift register into C
    ' rrf R_DATEN,F ;To daten () negates
    ' ----------------------------------------
    
    if B_in = 1 then
       STATUS.0 = 0
       R_DATEN = R_DATEN >> 1
    else
       STATUS.0 = 1
    endif
    I'll really appreciate to be corrected by somebody here if i'm not right on that.
    Last edited by mister_e; - 6th February 2005 at 19:28.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    zugvogel1's Avatar
    zugvogel1 Guest


    Did you find this post helpful? Yes | No

    Post Need once your help one please

    Need once your help one please.
    Who can follow me at would cut off ASM.......ENDASM help there I not point as I can write the one pic Basic.
    To Thanks onto all of them in advance.

    Therefore everything what would like between ASM....and....Endasm I also still pic Basic have

    S88.bas
    ;-------------------------------------------------------------------------------

    B_CLK var PORTB.0 ' B_CLK to PORTB.0
    B_OUT var PORTB.1 ' B_OUT to PORTB.1
    B_LED var PORTB.2 ' B_IN to PORTB.6
    B_IN var PORTB.6 ' B_IN to PORTB.6
    B_PS var PORTB.7 ' B_PS to PORTB.7

    R_DATEN var BYTE
    ;-------------------------------------------------------------------------------

    asm
    R_DATEN equ 20h ; fuer Speichern der Daten und Schieben
    R_OLD equ 25h ; Register for old values
    R_FLAG equ 26h ; Register for flags
    F_PS_RDY equ d'1' ; Ready-Flag


    A_X1 equ d'1' ; Port A7, X1
    A_X2 equ d'0' ; Port A6, X2
    A_X3 equ d'7' ; Port A5, X3
    A_X4 equ d'6' ; Port A4, X4
    A_X5 equ d'5' ; Port A3, X5
    A_X6 equ d'4' ; Port A2, X6
    A_X7 equ d'3' ; Port A1, X7
    A_X8 equ d'2' ; Port A0, X8

    B_CLK equ d'0' ; Port B, Clock
    B_OUT equ d'1' ; Port B, Data-OUT
    B_IN equ d'6' ; Port B, Data-IN
    B_PS equ d'7' ; Port B, PS-Eingang

    endasm

    INTCON.0 =1 ;wenn RB0-Int(CLK) =1 dann
    goto start ;gehe zu Start
    INTCON.0 =0 ;wenn RB0-Int(CLK) =0 dann clear IR-Flag
    ;--------------------------------------------------------------------------------
    asm
    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

    endasm
    ;--------------------------------------------------------------------------------
    If B_CLK <>1 then
    B_LED =0
    else
    toggle B_LED
    endif
    If B_PS =0 then gosub lesen
    ;--------------------------------------------------------------------------------

    asm
    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).
    endasm
    ;--------------------------------------------------------------------------------
    start:

    TRISB = %111110001 ' Set PORTB to output 0=Out 1=In
    TRISA = %11111111 ' Set PORTA to input
    CMCON = 7 ' PORTA to digital
    OPTION_REG = $87 ' Konfiguration TIMER / WDT / Pull-Ups Disable PORTB pull-ups und PS2-PS0 Prescaler Rate Select bits
    INTCON = $F0 ' Konfiguration INTERRUPT Disable PORTB pull-ups und PS2-PS0 Prescaler Rate Select bits

    asm
    loop
    clrwdt ; Watchdog-Timer loeschen
    btfsc PORTB,B_PS ; if PS = LOW
    goto loop2
    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
    endasm

    lesen:

    asm
    read_input
    clrf R_DATEN
    btfss PORTA,A_X8
    bsf R_DATEN,0
    btfss PORTA,A_X7
    bsf R_DATEN,1
    btfss PORTA,A_X6
    bsf R_DATEN,2
    btfss PORTA,A_X5
    bsf R_DATEN,3
    btfss PORTA,A_X4
    bsf R_DATEN,4
    btfss PORTA,A_X3
    bsf R_DATEN,5
    btfss PORTA,A_X2
    bsf R_DATEN,6
    btfss PORTA,A_X1
    bsf R_DATEN,7

    movf R_DATEN,W
    movwf R_OLD

    endasm
    return

    end

  4. #4
    PICtron's Avatar
    PICtron Guest


    Did you find this post helpful? Yes | No

    Default

    Zugvogel,

    CHECK PM

  5. #5
    PICtron's Avatar
    PICtron Guest


    Did you find this post helpful? Yes | No

    Default

    Zugvogel

    What I undersand from you PM is:
    We are talking about S88 Bus.

    I don't know this bus,
    but what I read from your short description it can't be much of a problem to solve this in PBP.

    - What type of PIC are you using?
    - What type of shift registers are you using?
    - How many "Feedback" lines are there?

    Could you post a schematic?

  6. #6
    zugvogel1's Avatar
    zugvogel1 Guest


    Did you find this post helpful? Yes | No

    Default Hilfe bei Picbasic

    Hallo

    Pic-16F628-4
    Clk-kommt von der Zentrale (Intellibox)
    Reset entfällt da pic und keine schiftregister.

    siehe mal hier:
    http://www.digital-bahn.de/rueckm/s88.htm
    http://www.ldt-infocenter.com/hsi88.htm

  7. #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