logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

Nastepny problem z programem Bascom

barin 17 Gru 2009 10:07 1068 5
REKLAMA
  • #1 7400222
    barin
    Poziom 10  
    Napisałem programik:
    Cytat:
    $regfile = "attiny2313.dat"
    $crystal = 1000000


    Config Portb = Input
    Portb = &B11111111
    Config Portd.4 = Output
    Portd.4 = 1
    Config Portd.0 = Output
    Portd.0 = 1
    Config Portd.1 = Input
    Portd.1 = 1
    Config Portd.2 = Output
    Portd.2 = 0

    Do

    If Pind.1 = 0 Then
    Waitms 100
    Portd.0 = 0
    Waitms 100
    Portd.0 = 1
    Portd.2 = 1
    Wait 1
    Portd.2 = 0


    End If

    If Pind.1 = 0 And Pinb.1 = 0 Then
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1

    End If

    If Pind.1 = 0 And Pinb.2 = 0 Then
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1

    End If

    If Pind.1 = 0 And Pinb.3 = 0 Then
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1

    End If

    If Pind.1 = 0 And Pinb.4 = 0 Then
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1

    End If

    If Pind.1 = 0 And Pinb.5 = 0 Then
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1

    End If

    If Pind.1 = 0 And Pinb.6 = 0 Then
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1

    End If

    If Pind.1 = 0 And Pinb.7 = 0 Then
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1
    Portd.4 = 0
    Waitms 1
    Portd.4 = 1
    Waitms 1

    End If
    Loop

    End 'end program


    I tak jak na PD1 i PD2 są złączone switchem.
    jak moje urządzenie dostanie sygnał z PD0 to daje sygnał na nogi PB0-6
    Znaczy ma dawać bo sekwencji migania LED nie ma.
    Co możne być żle?
  • REKLAMA
  • REKLAMA
  • #3 7400383
    Logan
    Poziom 30  
    K_o_n_r_a_d napisał:
    Tu jest błąd:
    Config Portd.4 = Output 

    Jesli konfigurujesz pojedyncze piny to nie PORT a PIN.
    Czyli:
    Config Pind.4 = Output 


    Chyba niekoniecznie, bo ja u siebie mam np. coś takiego:

    
    Config Portc.0 = Output : Set Portc.0 : Spk Alias Portc.0
    Config Portc.1 = Output : Set Portc.1 : Grzalka Alias Portc.1
    Config Portc.2 = Input : Set Portc.2 : Enter Alias Pinc.2
    Config Portc.3 = Input : Set Portc.0.3 : Zmien Alias Pinc.3
    

    i działa. Proszę zwrócić uwagę, że dla wejść aliasy przypisane są dla pinów, a nie portów.
  • REKLAMA
  • #4 7400498
    sp3ots
    Poziom 38  
    Witam !
    Przy opóźnieniu :
    waitms 1 pulsowania nie zobaczysz !
    daj opóźnienie
    waitms 100 ' 100mili sekund lub 200
    Pozdrawiam. Stefan
  • REKLAMA
  • #5 7400533
    K_o_n_r_a_d
    Poziom 23  
    Logan napisał:
    K_o_n_r_a_d napisał:
    Tu jest błąd:
    Config Portd.4 = Output 

    Jesli konfigurujesz pojedyncze piny to nie PORT a PIN.
    Czyli:
    Config Pind.4 = Output 


    Chyba niekoniecznie, bo ja u siebie mam np. coś takiego:

    
    Config Portc.0 = Output : Set Portc.0 : Spk Alias Portc.0
    Config Portc.1 = Output : Set Portc.1 : Grzalka Alias Portc.1
    Config Portc.2 = Input : Set Portc.2 : Enter Alias Pinc.2
    Config Portc.3 = Input : Set Portc.0.3 : Zmien Alias Pinc.3
    

    i działa. Proszę zwrócić uwagę, że dla wejść aliasy przypisane są dla pinów, a nie portów.
    Dawno Bascoma nie używałem, ale wg. pomocy do Bascoma jest właśnie tak jak napisałem.

    Takie coś:
    Config Portc.2 = Input

    lub też:
    Config Pinc.2 = Input

    na POCZĄTKU programu, gdy jeszcze rejestry portu nie były zmieniane i tak nic nie zmienia, dlatego działało będzie.

    Może sterujesz np. tranzystorem i sam rezystor wbudowany wystarcza do wysterowania go i dlatego działa?

    Być może Bascom już dopuszcza konstrukcję:
    Config Portc.0 = Output
    W pliku pomocy jest napisane tak jak w poprzedniej wypowiedzi napisałem. Jak będę miał okazję sprawdzę i zweryfikuję.
  • #6 7400989
    barin
    Poziom 10  
    sp3ots napisał:
    Witam !
    Przy opóźnieniu :
    waitms 1 pulsowania nie zobaczysz !
    daj opóźnienie
    waitms 100 ' 100mili sekund lub 200
    Pozdrawiam. Stefan

    Zmieniłem na 100 ale dalej nic mignie raz ja jakiś czas ale tylko 1 mignięcie.
REKLAMA