PORTA tanımlama

Başlatan onurinci, 24 Aralık 2022, 11:43:27

onurinci

Rosetta'nın hiç değişiklik yapmadan VU.bas dosyasını simule etmeyi denedim.aksakda olsa bir şeyler çalışıyor. LES bir hatamı yapmış,ücretsiz derleyicidemi hata var anlamadım.PORTA çıkış olarak kalıyor TRISA=%11111111 eklememe rağmen tepki oluşmuyor.aşağı kısımda PORTB 0...7 kadar yazılmış olmasına rağmen sadece 3 port tepki veriyor.yoksa netten bulduğum Proteus'mu saçmalıyor anlayamadım.
' Program to display result of ADC in 3 segment bargraph.
' The last LED in the graph dims or brightens with changes in the analogue input.
'
' Written by Les Johnson for the Proton BASIC compiler.

'
    Device = 16F877
    Declare Xtal = 4
'
' Define ADC parameters
'
    Declare Adin_Res = 10              ' 10-bit result required
    Declare Adin_Tad = FRC              ' RC OSC chosen
    Declare Adin_Stime = 50            ' Allow 50us sample time

    Dim AdVal As Byte                  ' ADC result variable
    Dim I As Byte                      ' For-loop variable
    Dim Position As Byte                ' LED position variable
    Dim Bright As Byte                  ' Brightness variable

'------------------------------------------------------------
' Main Program Begins Here
'
    ADCON1 = %00000010                  ' Set PORTA analogue

    Do
        AdVal = ADIn 0                  ' Store ADC value to adval
        Position = AdVal / 85          ' Position of last lit LED
        Bright = (AdVal // 85) * 3      ' Brightness of last lit LED
        For I = 0 To 7                  ' Set each LED
            If I < Position Then
                High I                  ' Turn on if lower than last lit LED
            Else
                Low I                  ' Turn off if higher than last lit
            EndIf
        Next
        '
        ' Dim the last LED
        '
        If Position = 0 Then
            PWM PORTB.0,Bright,5
        Else If Position = 1 Then
            PWM PORTB.1,Bright,5
        Else If Position = 2 Then
            PWM PORTB.2,Bright,5
        Else If Position = 3 Then
            PWM PORTB.3,Bright,5
        Else If Position = 4 Then
            PWM PORTB.4,Bright,5
        Else If Position = 5 Then
            PWM PORTB.5,Bright,5
        Else If Position = 6 Then
            PWM PORTB.6,Bright,5
        Else If Position = 7 Then
            PWM PORTB.7,Bright,5
        EndIf
    Loop                                ' Do it forever



Basic Pro örneği ise düzgün çalışıyor..

' Define ADCIN parameters
Define ADC_BITS     8   ' Set number of bits in result
Define ADC_CLOCK    3   ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50  ' Set sampling time in uS

adval    Var Byte       ' ADC result variable
i        Var Byte       ' For-loop variable
position Var Byte       ' LED position variable
bright   Var Byte       ' Brightness variable

   ADCON1 = %00000010   ' Set PORTA analog

mainloop:
   ADCIN 0, adval             ' Store ADC value to adval
   position = adval / 85      ' Position of last lit LED
   bright = (adval // 85) * 3 ' Brightness of last lit LED

   For i = 0 To 2             ' Set each LED
     If i < position Then
        High i  ' Turn on if lower than last lit LED 
     Else
        Low i   ' Turn off if higher than last lit
     Endif
   Next i
   PWM position,bright,5      ' Dim the last LED
   Goto mainloop              ' Do it forever

   End

onurinci

yanıta gerek kalmamıştır konu kaldırılabilir.Demo sürümü hatalı.Sonsivri'den PRplus desteği ile hallettim..

Powered by EzPortal