Şimdi Ara

PIC çıkışa gönderilecek sayıyı invert yapmak

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
1 Misafir - 1 Masaüstü
5 sn
22
Cevap
0
Favori
527
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 12
Sayfaya Git
Git
sonraki
Giriş
Mesaj
  • Merhaba. Bir tane devre var. Pic16f627'nin içindeki timer'in ürettiği dört bitlik sayısal değeri portb_0:3 bitlerinden 4511 7-segment decoder entegresine gönderiyor. Entegre kodu çözüp display'i sürüyor.
    Ben aynı devreyi 4511'ile aynı pin yapısına sahip ancak open collector çıkışlara sahip olan 7447 ile yapacağım. 7447 öpen collector olduğu icin anot display ile kullanılabiliyor.

    Ancak 4511'in girişleri normalken, 7447'nin girişleri active low. Yani 4511'lin lojik 1 olarak gördüğü değeri 7447 lojik 0 olarak görüyor.

    Pic'in çıkışlarına transistör ekleyerek elektriksel olarak invert edebilirim. Ancak devre karmaşıklaşacak.

    Bunun yerine yazılımdan invert etmenin yolu var mı?

    Şöyle yani, üretilen sayı 0001 olsun, bunu 1110 yapıp çıkışa göndereceğiz. İşlem bu.

    quote:


    ;------------------------------------------------------------------------------------------------------------------------
    ; Source code for the PIC16F627 based Low Cost CPU Fan Speed Tester.
    ;------------------------------------------------------------------------------------------------------------------------
    ;
    ; **Fan Tachometer
    ; TMR0 is the counter for the fan clock pulses.
    ; TMR1 is the timer to time every 0.5 seconds.
    ;
    ; **Output to CD4511
    ; RB0 - RB3 for digits.
    ; RB4 - RB6 for 7 segment selector.
    ;
    ; RB4 - 2nd digit from the right. (Numbers in RPM)
    ; RB5 - 3rd digit from the right.
    ; RB6 - 4th digit from the right.
    ; RB7 - 1st digit from the right. (Random number XD)
    ;
    ; Instruction Cycle Time = 1 / (4MHz / 4) = 1us per instruction
    ;------------------------------------------------------------------------------------------------------------------------

    LIST P=16F627
    INCLUDE "p16f627.inc"
    ; ERRORLEVEL -302
    __CONFIG _PWRTE_OFF & _HS_OSC & _WDT_OFF & _LVP_OFF & _BODEN_OFF; configuration switches

    CBlock 0x20
    rmng_num ; Digit breaker registers.
    temp_num
    quotient

    N ; Delay registers.
    FIXDELAY

    digitfan0 ; Individual digit registers.
    digitfan1
    digitfan2
    digitfan3
    prevdigitfan0

    multiplier ; Manipulator storage registers.
    adder
    passer
    pulsetotal
    rdmhold
    prevfreq
    prevpulse
    EndC

    org 0x00
    nop
    goto start

    org 0x04
    goto ISR ; Interrupt Vector.

    start call initports
    call initTMRnINT

    awaitint call displayfanspd
    movf TMR1L, w ; Generate random number.
    movwf rdmhold
    movlw 0x0F
    andwf rdmhold, f
    goto awaitint ; Wait for interrupt to happen.

    ;------------------------------------------------------------------------------------------------------------------------
    ; Subroutine to initialize the PORTs as Inputs or Outputs.
    ;------------------------------------------------------------------------------------------------------------------------

    initports
    banksel PORTB
    clrf PORTB

    banksel TRISB ; Select TRISB bank.
    movlw 0x00 ; Define PORTB as Outputs.
    movwf TRISB

    return

    ;------------------------------------------------------------------------------------------------------------------------
    ; Initialize Timer and Interrupts Subroutine.
    ;------------------------------------------------------------------------------------------------------------------------

    initTMRnINT
    banksel INTCON ; Enable all unmasked interrupts and peripheral interrupts.
    movlw b'11000000'
    movwf INTCON

    banksel PIE1 ; Enable TMR1 overflow interrupt.
    movlw b'00000001'
    movwf PIE1

    banksel OPTION_REG ; 1:1 Prescaler to TMR0, rising edge of the clock, Clock = RA4 Transition, TMR0 as counter.
    movlw b'11101000'
    movwf OPTION_REG

    banksel T1CON ; 1:8 Prescalar to TMR1, osc off, internal Fosc/4 clock, Enable TMR1.
    movlw b'00110001'
    movwf T1CON

    return

    ;------------------------------------------------------------------------------------------------------------------------
    ; Interrupt Service Routine. (ISR)
    ;------------------------------------------------------------------------------------------------------------------------

    ISR
    btfss PIR1, TMR1IF ; Check if TMR1 overflowed.
    goto intdone ; If no, return from interrupt. Else, service interrupts.
    beginISR bcf T1CON, TMR1ON ; Disable TMR1.
    bcf PIR1, TMR1IF ; Clear TMR1 interrupt flag.
    movf TMR0, w

    movwf prevfreq ; Pass TMR0 value to pulse counters.
    movwf rmng_num
    movwf pulsetotal

    movf prevpulse, w ; Adds previous fan speed value to current fan speed value and average the two.
    addwf rmng_num, f
    bcf STATUS, C ; Divides summed value by 2.
    rrf rmng_num, f

    call breakdigitfanspd ; Break pulse total to individual digits.
    call convertrpm ; Convert Hertz to RPM.
    movf prevfreq, w ; Pass previous counted frequency to prevpulse.
    movwf prevpulse
    clrf TMR1L ; Clear all timers.
    clrf TMR1H
    clrf TMR0
    bsf T1CON, TMR1ON ; Re-enable TMR1.
    intdone retfie

    ;------------------------------------------------------------------------------------------------------------------------
    ; N DELAY SUBROUTINE, delay in multiples of 200us up to 200us*255 = 51ms (or more)
    ;------------------------------------------------------------------------------------------------------------------------

    NDELAY
    MOVWF N ; N is delay multiplier
    NOTOVER CALL DELAY200 ; Call for 200us
    DECFSZ N, 1 ; Decrease N by 1
    GOTO NOTOVER ; The delay isn't done
    RETURN

    ;------------------------------------------------------------------------------------------------------------------------
    ; FIXED 200us DELAY (Possibly more due to execution time of the DECFSZ instruction.)
    ;------------------------------------------------------------------------------------------------------------------------

    DELAY200
    MOVLW 0x42 ; 66 LOOPS
    MOVWF FIXDELAY ; 200us fixed delay
    NOTDONE200 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAY
    GOTO NOTDONE200 ; If 200us isn't up go back to NOTDONE200
    RETURN ; If 200us is up then return to instruction.

    ;------------------------------------------------------------------------------------------------------------------------
    ; Breaks down the temperature reading to its individual digits.
    ;------------------------------------------------------------------------------------------------------------------------

    get_dig
    movlw d'10' ; To split the digits, divide them by 10.
    incf quotient, f ; Increment of quotient with each subtraction by 10.
    subwf rmng_num, f ; Subtract the number by 10.
    skpnc ; If already negative, stop division.
    goto get_dig ; Else, continue dividing.
    addwf rmng_num, f ; Restore number.
    decf quotient, f ; Restore quotient.

    movf rmng_num, w ; Move rmng_num to temp_num.
    movwf temp_num
    movf quotient, w ; Move quotient to rmng_num.
    movwf rmng_num
    movf temp_num, w

    return

    ;------------------------------------------------------------------------------------------------------------------------
    ; Break down fanspeed to individual digits.
    ;------------------------------------------------------------------------------------------------------------------------

    breakdigitfanspd

    clrf quotient
    call get_dig ; Get 1st digit.
    movwf digitfan0

    clrf quotient
    call get_dig ; Get 2nd digit.
    movwf digitfan1

    clrf quotient
    call get_dig ; Get 3rd digit.
    movwf digitfan2

    return

    ;------------------------------------------------------------------------------------------------------------------------
    ; Convert frequency to RPM.
    ;------------------------------------------------------------------------------------------------------------------------

    convertrpm
    banksel multiplier ; Fan Speed in RPM = Fan Speed in Hz * 60
    digitfanspd0x6 movlw d'6'
    movwf multiplier
    movf digitfan0, w
    movwf adder

    keepmult0 movf adder, w
    addwf digitfan0, f
    decfsz multiplier, f
    goto keepmult0
    subwf digitfan0, f
    movlw d'10'
    keeppass0 incf passer, f
    subwf digitfan0, f
    skpnc
    goto keeppass0
    addwf digitfan0, f
    decf passer, f

    digitfanspd1x6 movlw d'6'
    movwf multiplier
    movf digitfan1, w
    movwf adder

    keepmult1 movf adder, w
    addwf digitfan1, f
    decfsz multiplier, f
    goto keepmult1
    subwf digitfan1, f
    movf passer, w
    addwf digitfan1, f
    clrf passer

    movlw d'10'
    keeppass1 incf passer, f
    subwf digitfan1, f
    skpnc
    goto keeppass1
    addwf digitfan1, f
    decf passer, f


    digitfanspd2x6 movlw d'6'
    movwf multiplier
    movf digitfan2, w
    movwf adder

    keepmult2 movf adder, w
    addwf digitfan2, f
    decfsz multiplier, f
    goto keepmult2
    subwf digitfan2, f
    movf passer, w
    addwf digitfan2, f
    clrf passer
    movlw d'10'
    keeppass2 incf passer, f
    subwf digitfan2, f
    skpnc
    goto keeppass2
    addwf digitfan2, f
    decf passer, f

    spincheck movlw d'0' ; Checks if the fan is actually spinning.
    subwf pulsetotal, f
    skpnz
    goto notspinning
    goto spinning

    notspinning movlw d'0' ; If not spinning then write 0 to the last digit.
    movwf digitfan3
    goto rpmconvdone

    spinning movlw d'10' ; If it is spinning display the generated random number.
    subwf rdmhold, f
    skpc
    addwf rdmhold, f
    movf rdmhold, w
    movwf digitfan3
    goto rpmconvdone

    rpmconvdone clrf passer
    return

    ;------------------------------------------------------------------------------------------------------------------------
    ; Display fan speed on 7 segment displays.
    ;------------------------------------------------------------------------------------------------------------------------

    displayfanspd
    bsf PORTB, 4 ; Display digit0.
    bcf PORTB, 5
    bcf PORTB, 6
    bcf PORTB, 7

    movf prevdigitfan0, w ; Obtain average value for digit0 from the current and previous values.
    addwf digitfan0, f
    bcf STATUS, C
    rrf digitfan0, f

    movlw 0xF0 ; Strip lower 4 bits.
    andwf PORTB, f
    movf digitfan0, w
    iorwf PORTB, f

    movf digitfan0, w ; Pass current digitfan0 value to previous value.
    movwf prevdigitfan0

    movlw d'20' ; Small delay for viewing.
    call NDELAY

    bcf PORTB, 4 ; Display digit1.
    bsf PORTB, 5
    bcf PORTB, 6
    bcf PORTB, 7

    movlw 0xF0
    andwf PORTB, f
    movf digitfan1, w
    iorwf PORTB, f

    movlw d'20' ; Small delay for viewing.
    call NDELAY

    bcf PORTB, 4 ; Display digit2.
    bcf PORTB, 5
    bsf PORTB, 6
    bcf PORTB, 7

    movlw 0xF0
    andwf PORTB, f
    movf digitfan2, w
    iorwf PORTB, f

    movlw d'20' ; Small delay for viewing.
    call NDELAY

    bcf PORTB, 4 ; Display digit2.
    bcf PORTB, 5
    bcf PORTB, 6
    bsf PORTB, 7

    movlw 0xF0
    andwf PORTB, f
    movf digitfan3, w
    iorwf PORTB, f

    movlw d'20' ; Small delay for viewing.
    call NDELAY

    return

    ;------------------------------------------------------------------------------------------------------------------------
    ; End of programme.
    ;------------------------------------------------------------------------------------------------------------------------

    end



    < Bu mesaj bu kişi tarafından değiştirildi ipli jeton -- 5 Ekim 2021; 18:49:17 >
    < Bu ileti mini sürüm kullanılarak atıldı >







  • Tabiki yapılabilir. Kodları paylaşırsanız çözüm önermek isteyenler için kolaylık sağlamış olursunuz.

    < Bu ileti mobil sürüm kullanılarak atıldı >
  • Telefondan yukarıdaki mesajı yazarken kodlar mesajinizda yoktu. Sonradan editlediniz sanırım.

    < Bu ileti mobil sürüm kullanılarak atıldı >
  • movlw 0xF0

    andwf PORTB, f

    comf PORTB,1 ; tersleme komutu ekledik

    movf digitfan3, w

    iorwf PORTB, f


    Rafet hocam, çıkışlar kodların en altındaki kısımdan ayarlanıyor galiba,

    diğer dördünü de şu yaptığım gibi hazırlayıp arkadaşa yükleteyim mi ? @rafet32




    < Bu mesaj bu kişi tarafından değiştirildi hllkntrc -- 5 Ekim 2021; 23:18:56 >
  • Devrede bozulacak birşey yok ise şu kodu deneyin derim,



    ;------------------------------------------------------------------------------------------------------------------------

    ; Source code for the PIC16F627 based Low Cost CPU Fan Speed Tester.

    ;------------------------------------------------------------------------------------------------------------------------

    ;

    ; **Fan Tachometer

    ; TMR0 is the counter for the fan clock pulses.

    ; TMR1 is the timer to time every 0.5 seconds.

    ;

    ; **Output to CD4511

    ; RB0 - RB3 for digits.

    ; RB4 - RB6 for 7 segment selector.

    ;

    ; RB4 - 2nd digit from the right. (Numbers in RPM)

    ; RB5 - 3rd digit from the right.

    ; RB6 - 4th digit from the right.

    ; RB7 - 1st digit from the right. (Random number XD)

    ;

    ; Instruction Cycle Time = 1 / (4MHz / 4) = 1us per instruction

    ;------------------------------------------------------------------------------------------------------------------------


    LIST P=16F627

    INCLUDE "p16f627.inc"

    ; ERRORLEVEL -302

    __CONFIG _PWRTE_OFF & _HS_OSC & _WDT_OFF & _LVP_OFF & _BODEN_OFF; configuration switches


    CBlock 0x20

    rmng_num ; Digit breaker registers.

    temp_num

    quotient


    N ; Delay registers.

    FIXDELAY


    digitfan0 ; Individual digit registers.

    digitfan1

    digitfan2

    digitfan3

    prevdigitfan0


    multiplier ; Manipulator storage registers.

    adder

    passer

    pulsetotal

    rdmhold

    prevfreq

    prevpulse

    EndC


    org 0x00

    nop

    goto start


    org 0x04

    goto ISR ; Interrupt Vector.


    start call initports

    call initTMRnINT


    awaitint call displayfanspd

    movf TMR1L, w ; Generate random number.

    movwf rdmhold

    movlw 0x0F

    andwf rdmhold, f

    goto awaitint ; Wait for interrupt to happen.


    ;------------------------------------------------------------------------------------------------------------------------

    ; Subroutine to initialize the PORTs as Inputs or Outputs.

    ;------------------------------------------------------------------------------------------------------------------------


    initports

    banksel PORTB

    clrf PORTB


    banksel TRISB ; Select TRISB bank.

    movlw 0x00 ; Define PORTB as Outputs.

    movwf TRISB


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Initialize Timer and Interrupts Subroutine.

    ;------------------------------------------------------------------------------------------------------------------------


    initTMRnINT

    banksel INTCON ; Enable all unmasked interrupts and peripheral interrupts.

    movlw b'11000000'

    movwf INTCON


    banksel PIE1 ; Enable TMR1 overflow interrupt.

    movlw b'00000001'

    movwf PIE1


    banksel OPTION_REG ; 1:1 Prescaler to TMR0, rising edge of the clock, Clock = RA4 Transition, TMR0 as counter.

    movlw b'11101000'

    movwf OPTION_REG


    banksel T1CON ; 1:8 Prescalar to TMR1, osc off, internal Fosc/4 clock, Enable TMR1.

    movlw b'00110001'

    movwf T1CON


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Interrupt Service Routine. (ISR)

    ;------------------------------------------------------------------------------------------------------------------------


    ISR

    btfss PIR1, TMR1IF ; Check if TMR1 overflowed.

    goto intdone ; If no, return from interrupt. Else, service interrupts.

    beginISR bcf T1CON, TMR1ON ; Disable TMR1.

    bcf PIR1, TMR1IF ; Clear TMR1 interrupt flag.

    movf TMR0, w


    movwf prevfreq ; Pass TMR0 value to pulse counters.

    movwf rmng_num

    movwf pulsetotal


    movf prevpulse, w ; Adds previous fan speed value to current fan speed value and average the two.

    addwf rmng_num, f

    bcf STATUS, C ; Divides summed value by 2.

    rrf rmng_num, f


    call breakdigitfanspd ; Break pulse total to individual digits.

    call convertrpm ; Convert Hertz to RPM.

    movf prevfreq, w ; Pass previous counted frequency to prevpulse.

    movwf prevpulse

    clrf TMR1L ; Clear all timers.

    clrf TMR1H

    clrf TMR0

    bsf T1CON, TMR1ON ; Re-enable TMR1.

    intdone retfie


    ;------------------------------------------------------------------------------------------------------------------------

    ; N DELAY SUBROUTINE, delay in multiples of 200us up to 200us*255 = 51ms (or more)

    ;------------------------------------------------------------------------------------------------------------------------


    NDELAY

    MOVWF N ; N is delay multiplier

    NOTOVER CALL DELAY200 ; Call for 200us

    DECFSZ N, 1 ; Decrease N by 1

    GOTO NOTOVER ; The delay isn't done

    RETURN


    ;------------------------------------------------------------------------------------------------------------------------

    ; FIXED 200us DELAY (Possibly more due to execution time of the DECFSZ instruction.)

    ;------------------------------------------------------------------------------------------------------------------------


    DELAY200

    MOVLW 0x42 ; 66 LOOPS

    MOVWF FIXDELAY ; 200us fixed delay

    NOTDONE200 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAY

    GOTO NOTDONE200 ; If 200us isn't up go back to NOTDONE200

    RETURN ; If 200us is up then return to instruction.


    ;------------------------------------------------------------------------------------------------------------------------

    ; Breaks down the temperature reading to its individual digits.

    ;------------------------------------------------------------------------------------------------------------------------


    get_dig

    movlw d'10' ; To split the digits, divide them by 10.

    incf quotient, f ; Increment of quotient with each subtraction by 10.

    subwf rmng_num, f ; Subtract the number by 10.

    skpnc ; If already negative, stop division.

    goto get_dig ; Else, continue dividing.

    addwf rmng_num, f ; Restore number.

    decf quotient, f ; Restore quotient.


    movf rmng_num, w ; Move rmng_num to temp_num.

    movwf temp_num

    movf quotient, w ; Move quotient to rmng_num.

    movwf rmng_num

    movf temp_num, w


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Break down fanspeed to individual digits.

    ;------------------------------------------------------------------------------------------------------------------------


    breakdigitfanspd


    clrf quotient

    call get_dig ; Get 1st digit.

    movwf digitfan0


    clrf quotient

    call get_dig ; Get 2nd digit.

    movwf digitfan1


    clrf quotient

    call get_dig ; Get 3rd digit.

    movwf digitfan2


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Convert frequency to RPM.

    ;------------------------------------------------------------------------------------------------------------------------


    convertrpm

    banksel multiplier ; Fan Speed in RPM = Fan Speed in Hz * 60

    digitfanspd0x6 movlw d'6'

    movwf multiplier

    movf digitfan0, w

    movwf adder


    keepmult0 movf adder, w

    addwf digitfan0, f

    decfsz multiplier, f

    goto keepmult0

    subwf digitfan0, f

    movlw d'10'

    keeppass0 incf passer, f

    subwf digitfan0, f

    skpnc

    goto keeppass0

    addwf digitfan0, f

    decf passer, f


    digitfanspd1x6 movlw d'6'

    movwf multiplier

    movf digitfan1, w

    movwf adder


    keepmult1 movf adder, w

    addwf digitfan1, f

    decfsz multiplier, f

    goto keepmult1

    subwf digitfan1, f

    movf passer, w

    addwf digitfan1, f

    clrf passer


    movlw d'10'

    keeppass1 incf passer, f

    subwf digitfan1, f

    skpnc

    goto keeppass1

    addwf digitfan1, f

    decf passer, f



    digitfanspd2x6 movlw d'6'

    movwf multiplier

    movf digitfan2, w

    movwf adder


    keepmult2 movf adder, w

    addwf digitfan2, f

    decfsz multiplier, f

    goto keepmult2

    subwf digitfan2, f

    movf passer, w

    addwf digitfan2, f

    clrf passer

    movlw d'10'

    keeppass2 incf passer, f

    subwf digitfan2, f

    skpnc

    goto keeppass2

    addwf digitfan2, f

    decf passer, f


    spincheck movlw d'0' ; Checks if the fan is actually spinning.

    subwf pulsetotal, f

    skpnz

    goto notspinning

    goto spinning


    notspinning movlw d'0' ; If not spinning then write 0 to the last digit.

    movwf digitfan3

    goto rpmconvdone


    spinning movlw d'10' ; If it is spinning display the generated random number.

    subwf rdmhold, f

    skpc

    addwf rdmhold, f

    movf rdmhold, w

    movwf digitfan3

    goto rpmconvdone


    rpmconvdone clrf passer

    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Display fan speed on 7 segment displays.

    ;------------------------------------------------------------------------------------------------------------------------


    displayfanspd

    bsf PORTB, 4 ; Display digit0.

    bcf PORTB, 5

    bcf PORTB, 6

    bcf PORTB, 7


    movf prevdigitfan0, w ; Obtain average value for digit0 from the current and previous values.

    addwf digitfan0, f

    bcf STATUS, C

    rrf digitfan0, f


    movlw 0xF0 ; Strip lower 4 bits.

    andwf PORTB, f

    comf PORTB,1 ; tersleme komutu ekledik

    movf digitfan0, w

    iorwf PORTB, f


    movf digitfan0, w ; Pass current digitfan0 value to previous value.

    movwf prevdigitfan0


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    bcf PORTB, 4 ; Display digit1.

    bsf PORTB, 5

    bcf PORTB, 6

    bcf PORTB, 7


    movlw 0xF0

    andwf PORTB, f

    comf PORTB,1 ; tersleme komutu ekledik

    movf digitfan1, w

    iorwf PORTB, f


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    bcf PORTB, 4 ; Display digit2.

    bcf PORTB, 5

    bsf PORTB, 6

    bcf PORTB, 7


    movlw 0xF0

    andwf PORTB, f

    comf PORTB,1 ; tersleme komutu ekledik

    movf digitfan2, w

    iorwf PORTB, f


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    bcf PORTB, 4 ; Display digit2.

    bcf PORTB, 5

    bcf PORTB, 6

    bsf PORTB, 7


    movlw 0xF0

    andwf PORTB, f

    comf PORTB,1 ; tersleme komutu ekledik

    movf digitfan3, w

    iorwf PORTB, f


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; End of programme.

    ;------------------------------------------------------------------------------------------------------------------------





  • hllkntrc kullanıcısına yanıt
    Teşekkür ederim. Deneyeceğim.

    < Bu ileti mini sürüm kullanılarak atıldı >
  • hllkntrc kullanıcısına yanıt
    Maalesef kodları daha derlerken hata verdi.
    tanımlanamayan hata uyarısı veriyor.

    < Bu ileti mini sürüm kullanılarak atıldı >
  • Kodları telefon ekranından değil pc ekranından incelemek ve cevap yazmak daha kolay geldiği için dün akşam cevap yazamadım.


    @hllkntrc bahsettiğiniz yaklaşım yönteminiz doğru, fakat compf sonucunu doğrudan portb ye yazdırırsanız segment tarama bitlerinin değerini değiştirmiş olursunuz. Devre şeması paylaşılmadığı için paylaşılan kodlardan anlaşılan B portunun 0..3 bitleri bcd data, 4..7 bitleri segment seçmede kullanılıyor.


    Anladığım @ipli jeton sadece bcd çıkış olan 0..3 bitlerin terslenmesini istiyor.


    Programda digitfan0,digitfan1...digitfan3 değişkenlerinin içindeki değerler displayde gösteriliyor. Hız ölçümü için bu değişkenlerin önceki değerleri programın geri kalanında kullanılıyormu diye kontrol etmek yerine, gecici bir değişken daha tanımlayıp bit manüplasyon işlemlerini onun üzerinden yapmak daha mantıklı.



    Not: Segment seçme yapısında değişiklik yapılmadı !


    Yazım hatası yoksa kodumuz aşağıdaki gibi olacak. Yapılan değişiklikler kod içerisinde kırmızı ile renklendirildi.



    ;------------------------------------------------------------------------------------------------------------------------

    ; Source code for the PIC16F627 based Low Cost CPU Fan Speed Tester.

    ;------------------------------------------------------------------------------------------------------------------------

    ;

    ; **Fan Tachometer

    ; TMR0 is the counter for the fan clock pulses.

    ; TMR1 is the timer to time every 0.5 seconds.

    ;

    ; **Output to CD4511

    ; RB0 - RB3 for digits.

    ; RB4 - RB6 for 7 segment selector.

    ;

    ; RB4 - 2nd digit from the right. (Numbers in RPM)

    ; RB5 - 3rd digit from the right.

    ; RB6 - 4th digit from the right.

    ; RB7 - 1st digit from the right. (Random number XD)

    ;

    ; Instruction Cycle Time = 1 / (4MHz / 4) = 1us per instruction

    ;------------------------------------------------------------------------------------------------------------------------


    LIST P=16F627

    INCLUDE "p16f627.inc"

    ; ERRORLEVEL -302

    __CONFIG _PWRTE_OFF & _HS_OSC & _WDT_OFF & _LVP_OFF & _BODEN_OFF; configuration switches


    CBlock 0x20

    rmng_num ; Digit breaker registers.

    temp_num

    quotient


    N ; Delay registers.

    FIXDELAY


    digitfan0 ; Individual digit registers.

    digitfan1

    digitfan2

    digitfan3

    prevdigitfan0


    multiplier ; Manipulator storage registers.

    adder

    passer

    pulsetotal

    rdmhold

    prevfreq

    prevpulse


    gecici ; <<--- eklenen yeni değişken

    EndC


    org 0x00

    nop

    goto start


    org 0x04

    goto ISR ; Interrupt Vector.


    start call initports

    call initTMRnINT


    awaitint call displayfanspd

    movf TMR1L, w ; Generate random number.

    movwf rdmhold

    movlw 0x0F

    andwf rdmhold, f

    goto awaitint ; Wait for interrupt to happen.


    ;------------------------------------------------------------------------------------------------------------------------

    ; Subroutine to initialize the PORTs as Inputs or Outputs.

    ;------------------------------------------------------------------------------------------------------------------------


    initports

    banksel PORTB

    clrf PORTB


    banksel TRISB ; Select TRISB bank.

    movlw 0x00 ; Define PORTB as Outputs.

    movwf TRISB


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Initialize Timer and Interrupts Subroutine.

    ;------------------------------------------------------------------------------------------------------------------------


    initTMRnINT

    banksel INTCON ; Enable all unmasked interrupts and peripheral interrupts.

    movlw b'11000000'

    movwf INTCON


    banksel PIE1 ; Enable TMR1 overflow interrupt.

    movlw b'00000001'

    movwf PIE1


    banksel OPTION_REG ; 1:1 Prescaler to TMR0, rising edge of the clock, Clock = RA4 Transition, TMR0 as counter.

    movlw b'11101000'

    movwf OPTION_REG


    banksel T1CON ; 1:8 Prescalar to TMR1, osc off, internal Fosc/4 clock, Enable TMR1.

    movlw b'00110001'

    movwf T1CON


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Interrupt Service Routine. (ISR)

    ;------------------------------------------------------------------------------------------------------------------------


    ISR

    btfss PIR1, TMR1IF ; Check if TMR1 overflowed.

    goto intdone ; If no, return from interrupt. Else, service interrupts.

    beginISR bcf T1CON, TMR1ON ; Disable TMR1.

    bcf PIR1, TMR1IF ; Clear TMR1 interrupt flag.

    movf TMR0, w


    movwf prevfreq ; Pass TMR0 value to pulse counters.

    movwf rmng_num

    movwf pulsetotal


    movf prevpulse, w ; Adds previous fan speed value to current fan speed value and average the two.

    addwf rmng_num, f

    bcf STATUS, C ; Divides summed value by 2.

    rrf rmng_num, f


    call breakdigitfanspd ; Break pulse total to individual digits.

    call convertrpm ; Convert Hertz to RPM.

    movf prevfreq, w ; Pass previous counted frequency to prevpulse.

    movwf prevpulse

    clrf TMR1L ; Clear all timers.

    clrf TMR1H

    clrf TMR0

    bsf T1CON, TMR1ON ; Re-enable TMR1.

    intdone retfie


    ;------------------------------------------------------------------------------------------------------------------------

    ; N DELAY SUBROUTINE, delay in multiples of 200us up to 200us*255 = 51ms (or more)

    ;------------------------------------------------------------------------------------------------------------------------


    NDELAY

    MOVWF N ; N is delay multiplier

    NOTOVER CALL DELAY200 ; Call for 200us

    DECFSZ N, 1 ; Decrease N by 1

    GOTO NOTOVER ; The delay isn't done

    RETURN


    ;------------------------------------------------------------------------------------------------------------------------

    ; FIXED 200us DELAY (Possibly more due to execution time of the DECFSZ instruction.)

    ;------------------------------------------------------------------------------------------------------------------------


    DELAY200

    MOVLW 0x42 ; 66 LOOPS

    MOVWF FIXDELAY ; 200us fixed delay

    NOTDONE200 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAY

    GOTO NOTDONE200 ; If 200us isn't up go back to NOTDONE200

    RETURN ; If 200us is up then return to instruction.


    ;------------------------------------------------------------------------------------------------------------------------

    ; Breaks down the temperature reading to its individual digits.

    ;------------------------------------------------------------------------------------------------------------------------


    get_dig

    movlw d'10' ; To split the digits, divide them by 10.

    incf quotient, f ; Increment of quotient with each subtraction by 10.

    subwf rmng_num, f ; Subtract the number by 10.

    skpnc ; If already negative, stop division.

    goto get_dig ; Else, continue dividing.

    addwf rmng_num, f ; Restore number.

    decf quotient, f ; Restore quotient.


    movf rmng_num, w ; Move rmng_num to temp_num.

    movwf temp_num

    movf quotient, w ; Move quotient to rmng_num.

    movwf rmng_num

    movf temp_num, w


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Break down fanspeed to individual digits.

    ;------------------------------------------------------------------------------------------------------------------------


    breakdigitfanspd


    clrf quotient

    call get_dig ; Get 1st digit.

    movwf digitfan0


    clrf quotient

    call get_dig ; Get 2nd digit.

    movwf digitfan1


    clrf quotient

    call get_dig ; Get 3rd digit.

    movwf digitfan2


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Convert frequency to RPM.

    ;------------------------------------------------------------------------------------------------------------------------


    convertrpm

    banksel multiplier ; Fan Speed in RPM = Fan Speed in Hz * 60

    digitfanspd0x6 movlw d'6'

    movwf multiplier

    movf digitfan0, w

    movwf adder


    keepmult0 movf adder, w

    addwf digitfan0, f

    decfsz multiplier, f

    goto keepmult0

    subwf digitfan0, f

    movlw d'10'

    keeppass0 incf passer, f

    subwf digitfan0, f

    skpnc

    goto keeppass0

    addwf digitfan0, f

    decf passer, f


    digitfanspd1x6 movlw d'6'

    movwf multiplier

    movf digitfan1, w

    movwf adder


    keepmult1 movf adder, w

    addwf digitfan1, f

    decfsz multiplier, f

    goto keepmult1

    subwf digitfan1, f

    movf passer, w

    addwf digitfan1, f

    clrf passer


    movlw d'10'

    keeppass1 incf passer, f

    subwf digitfan1, f

    skpnc

    goto keeppass1

    addwf digitfan1, f

    decf passer, f



    digitfanspd2x6 movlw d'6'

    movwf multiplier

    movf digitfan2, w

    movwf adder


    keepmult2 movf adder, w

    addwf digitfan2, f

    decfsz multiplier, f

    goto keepmult2

    subwf digitfan2, f

    movf passer, w

    addwf digitfan2, f

    clrf passer

    movlw d'10'

    keeppass2 incf passer, f

    subwf digitfan2, f

    skpnc

    goto keeppass2

    addwf digitfan2, f

    decf passer, f


    spincheck movlw d'0' ; Checks if the fan is actually spinning.

    subwf pulsetotal, f

    skpnz

    goto notspinning

    goto spinning


    notspinning movlw d'0' ; If not spinning then write 0 to the last digit.

    movwf digitfan3

    goto rpmconvdone


    spinning movlw d'10' ; If it is spinning display the generated random number.

    subwf rdmhold, f

    skpc

    addwf rdmhold, f

    movf rdmhold, w

    movwf digitfan3

    goto rpmconvdone


    rpmconvdone clrf passer

    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; Display fan speed on 7 segment displays.

    ;------------------------------------------------------------------------------------------------------------------------


    displayfanspd

    bsf PORTB, 4 ; Display digit0.

    bcf PORTB, 5

    bcf PORTB, 6

    bcf PORTB, 7


    movf prevdigitfan0, w ; Obtain average value for digit0 from the current and previous values.

    addwf digitfan0, f

    bcf STATUS, C

    rrf digitfan0, f






    movlw 0xF0 ; Strip lower 4 bits.

    andwf PORTB, f

    ;movf digitfan0, w ; -- burası iptal

    movf digitfan0, w   ; <<---- yukarıda digitfanx değeri kullanılıyorsa

    movwf gecici          ; <<---- onu bozmmak için değer geçici bir değişkene alındı

    comf gecici, w ; <<--- geçici değerin bitleri tersine çevrildi ve sonuç W (akümülatöre) e yazıldı

    iorwf PORTB, f


    movf digitfan0, w ; Pass current digitfan0 value to previous value.

    movwf prevdigitfan0


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    bcf PORTB, 4 ; Display digit1.

    bsf PORTB, 5

    bcf PORTB, 6

    bcf PORTB, 7


    movlw 0xF0

    andwf PORTB, f

    ;movf digitfan1, w ; -- burası iptal

    movf digitfan1, w   ; <<---- yukarıda digitfanx değeri kullanılıyorsa

    movwf gecici          ; <<---- onu bozmmak için değer geçici bir değişkene alındı

    comf gecici, w ; <<--- geçici değerin bitleri tersine çevrildi ve sonuç W (akümülatöre) e yazıldı

    iorwf PORTB, f


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    bcf PORTB, 4 ; Display digit2.

    bcf PORTB, 5

    bsf PORTB, 6

    bcf PORTB, 7


    movlw 0xF0

    andwf PORTB, f

    ;movf digitfan2, w ; -- burası iptal

    movf digitfan2, w   ; <<---- yukarıda digitfanx değeri kullanılıyorsa

    movwf gecici          ; <<---- onu bozmmak için değer geçici bir değişkene alındı

    comf gecici, w ; <<--- geçici değerin bitleri tersine çevrildi ve sonuç W (akümülatöre) e yazıldı

    iorwf PORTB, f


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    bcf PORTB, 4 ; Display digit2.

    bcf PORTB, 5

    bcf PORTB, 6

    bsf PORTB, 7


    movlw 0xF0

    andwf PORTB, f

    ;movf digitfan3, w ; -- burası iptal

    movf digitfan3, w   ; <<---- yukarıda digitfanx değeri kullanılıyorsa

    movwf gecici          ; <<---- onu bozmmak için değer geçici bir değişkene alındı

    comf gecici, w ; <<--- geçici değerin bitleri tersine çevrildi ve sonuç W (akümülatöre) e yazıldı

    iorwf PORTB, f


    movlw d'20' ; Small delay for viewing.

    call NDELAY


    return


    ;------------------------------------------------------------------------------------------------------------------------

    ; End of programme.

    ;------------------------------------------------------------------------------------------------------------------------







    Edit: imla


    Edit2: Mesaj içeriğini sonradan okuyacaklar açısından, aşağıdaki mesajlarda bahsedilen koddaki düzeltmeler mesaj içeriğinde de yapıldı.




    < Bu mesaj bu kişi tarafından değiştirildi rafet32 -- 7 Ekim 2021; 9:13:16 >




  • rafet32 kullanıcısına yanıt
    Teşekkürler. Şema bu bu arada. Sadeleştirme adına kristal, direnç vs. bunları çizmedim. Zaten simülasyonda bunlara gerek de yok.
    PIC çıkışa gönderilecek sayıyı invert yapmak

    Kodlar yine derleme hatası verdi. Anladığım kadarı ile kaynağından müdahale etmek gerekecek. Yani convertrpm kısmından.



    < Bu mesaj bu kişi tarafından değiştirildi ipli jeton -- 6 Ekim 2021; 11:13:48 >
    < Bu ileti mini sürüm kullanılarak atıldı >
  • ipli jeton kullanıcısına yanıt

    Kodları nasıl ve hangi araçla derlemeye çalışıyorsunuz?


    Hata verdiği sırada ekran görüntüsü paylaşabilirmisiniz.

  • rafet32 kullanıcısına yanıt
    MPASM ile derliyorum.
    PIC çıkışa gönderilecek sayıyı invert yapmak
    Böyle bir hata veriyor.
    err dosyası
    quote:

    Warning[205] D:\CPUFAN.ASM 21 : Found directive in column 1. (LIST)
    Warning[205] D:\CPUFAN.ASM 22 : Found directive in column 1. (INCLUDE)
    Warning[205] D:\CPUFAN.ASM 24 : Found directive in column 1. (__CONFIG)
    Warning[205] D:\CPUFAN.ASM 26 : Found directive in column 1. (CBlock)
    Warning[205] D:\CPUFAN.ASM 49 : Found directive in column 1. (ENDC)
    Warning[205] D:\CPUFAN.ASM 51 : Found directive in column 1. (org)
    Warning[203] D:\CPUFAN.ASM 52 : Found opcode in column 1. (nop)
    Warning[203] D:\CPUFAN.ASM 53 : Found opcode in column 1. (goto)
    Warning[205] D:\CPUFAN.ASM 55 : Found directive in column 1. (org)
    Warning[203] D:\CPUFAN.ASM 56 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 59 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 62 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 63 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 64 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 65 : Found opcode in column 1. (andwf)
    Warning[203] D:\CPUFAN.ASM 66 : Found opcode in column 1. (goto)
    Warning[205] D:\CPUFAN.ASM 73 : Found directive in column 1. (banksel)
    Warning[203] D:\CPUFAN.ASM 74 : Found opcode in column 1. (clrf)
    Warning[205] D:\CPUFAN.ASM 76 : Found directive in column 1. (banksel)
    Warning[203] D:\CPUFAN.ASM 77 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 78 : Found opcode in column 1. (movwf)
    Message[302] D:\CPUFAN.ASM 78 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Warning[203] D:\CPUFAN.ASM 80 : Found opcode in column 1. (return)
    Warning[205] D:\CPUFAN.ASM 87 : Found directive in column 1. (banksel)
    Warning[203] D:\CPUFAN.ASM 88 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 89 : Found opcode in column 1. (movwf)
    Warning[205] D:\CPUFAN.ASM 91 : Found directive in column 1. (banksel)
    Warning[203] D:\CPUFAN.ASM 92 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 93 : Found opcode in column 1. (movwf)
    Message[302] D:\CPUFAN.ASM 93 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Warning[205] D:\CPUFAN.ASM 95 : Found directive in column 1. (banksel)
    Warning[203] D:\CPUFAN.ASM 96 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 97 : Found opcode in column 1. (movwf)
    Message[302] D:\CPUFAN.ASM 97 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Warning[205] D:\CPUFAN.ASM 99 : Found directive in column 1. (banksel)
    Warning[203] D:\CPUFAN.ASM 100 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 101 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 103 : Found opcode in column 1. (return)
    Warning[203] D:\CPUFAN.ASM 110 : Found opcode in column 1. (btfss)
    Warning[203] D:\CPUFAN.ASM 111 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 113 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 114 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 116 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 117 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 118 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 120 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 121 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 122 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 123 : Found opcode in column 1. (rrf)
    Warning[203] D:\CPUFAN.ASM 125 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 126 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 127 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 128 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 129 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 130 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 131 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 132 : Found opcode in column 1. (bsf)
    Warning[203] D:\CPUFAN.ASM 140 : Found opcode in column 1. (MOVWF)
    Warning[203] D:\CPUFAN.ASM 142 : Found opcode in column 1. (DECFSZ)
    Warning[203] D:\CPUFAN.ASM 143 : Found opcode in column 1. (GOTO)
    Warning[203] D:\CPUFAN.ASM 144 : Found opcode in column 1. (RETURN)
    Warning[203] D:\CPUFAN.ASM 151 : Found opcode in column 1. (MOVLW)
    Warning[203] D:\CPUFAN.ASM 152 : Found opcode in column 1. (MOVWF)
    Warning[203] D:\CPUFAN.ASM 154 : Found opcode in column 1. (GOTO)
    Warning[203] D:\CPUFAN.ASM 155 : Found opcode in column 1. (RETURN)
    Warning[203] D:\CPUFAN.ASM 162 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 163 : Found opcode in column 1. (incf)
    Warning[203] D:\CPUFAN.ASM 164 : Found opcode in column 1. (subwf)
    Warning[204] D:\CPUFAN.ASM 165 : Found pseudo-op in column 1. (skpnc)
    Warning[203] D:\CPUFAN.ASM 166 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 167 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 168 : Found opcode in column 1. (decf)
    Warning[203] D:\CPUFAN.ASM 170 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 171 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 172 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 173 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 174 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 176 : Found opcode in column 1. (return)
    Warning[203] D:\CPUFAN.ASM 184 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 185 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 186 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 188 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 189 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 190 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 192 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 193 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 194 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 196 : Found opcode in column 1. (return)
    Warning[205] D:\CPUFAN.ASM 203 : Found directive in column 1. (banksel)
    Warning[203] D:\CPUFAN.ASM 205 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 206 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 207 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 210 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 211 : Found opcode in column 1. (decfsz)
    Warning[203] D:\CPUFAN.ASM 212 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 213 : Found opcode in column 1. (subwf)
    Warning[203] D:\CPUFAN.ASM 214 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 216 : Found opcode in column 1. (subwf)
    Warning[204] D:\CPUFAN.ASM 217 : Found pseudo-op in column 1. (skpnc)
    Warning[203] D:\CPUFAN.ASM 218 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 219 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 220 : Found opcode in column 1. (decf)
    Warning[203] D:\CPUFAN.ASM 223 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 224 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 225 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 228 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 229 : Found opcode in column 1. (decfsz)
    Warning[203] D:\CPUFAN.ASM 230 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 231 : Found opcode in column 1. (subwf)
    Warning[203] D:\CPUFAN.ASM 232 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 233 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 234 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 236 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 238 : Found opcode in column 1. (subwf)
    Warning[204] D:\CPUFAN.ASM 239 : Found pseudo-op in column 1. (skpnc)
    Warning[203] D:\CPUFAN.ASM 240 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 241 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 242 : Found opcode in column 1. (decf)
    Warning[203] D:\CPUFAN.ASM 246 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 247 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 248 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 251 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 252 : Found opcode in column 1. (decfsz)
    Warning[203] D:\CPUFAN.ASM 253 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 254 : Found opcode in column 1. (subwf)
    Warning[203] D:\CPUFAN.ASM 255 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 256 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 257 : Found opcode in column 1. (clrf)
    Warning[203] D:\CPUFAN.ASM 258 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 260 : Found opcode in column 1. (subwf)
    Warning[204] D:\CPUFAN.ASM 261 : Found pseudo-op in column 1. (skpnc)
    Warning[203] D:\CPUFAN.ASM 262 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 263 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 264 : Found opcode in column 1. (decf)
    Warning[203] D:\CPUFAN.ASM 267 : Found opcode in column 1. (subwf)
    Warning[204] D:\CPUFAN.ASM 268 : Found pseudo-op in column 1. (skpnz)
    Warning[203] D:\CPUFAN.ASM 269 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 270 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 273 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 274 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 277 : Found opcode in column 1. (subwf)
    Warning[204] D:\CPUFAN.ASM 278 : Found pseudo-op in column 1. (skpc)
    Warning[203] D:\CPUFAN.ASM 279 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 280 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 281 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 282 : Found opcode in column 1. (goto)
    Warning[203] D:\CPUFAN.ASM 285 : Found opcode in column 1. (return)
    Warning[203] D:\CPUFAN.ASM 292 : Found opcode in column 1. (bsf)
    Warning[203] D:\CPUFAN.ASM 293 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 294 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 295 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 297 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 298 : Found opcode in column 1. (addwf)
    Warning[203] D:\CPUFAN.ASM 299 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 300 : Found opcode in column 1. (rrf)
    Warning[203] D:\CPUFAN.ASM 306 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 307 : Found opcode in column 1. (andwf)
    Warning[203] D:\CPUFAN.ASM 309 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 310 : Found opcode in column 1. (movwf)
    Error[122] D:\CPUFAN.ASM 311 : Illegal opcode (gecici)
    Warning[203] D:\CPUFAN.ASM 312 : Found opcode in column 1. (iorwf)
    Warning[203] D:\CPUFAN.ASM 314 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 315 : Found opcode in column 1. (movwf)
    Warning[203] D:\CPUFAN.ASM 317 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 318 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 320 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 321 : Found opcode in column 1. (bsf)
    Warning[203] D:\CPUFAN.ASM 322 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 323 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 325 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 326 : Found opcode in column 1. (andwf)
    Warning[203] D:\CPUFAN.ASM 328 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 329 : Found opcode in column 1. (movwf)
    Error[122] D:\CPUFAN.ASM 330 : Illegal opcode (gecici)
    Warning[203] D:\CPUFAN.ASM 331 : Found opcode in column 1. (iorwf)
    Warning[203] D:\CPUFAN.ASM 333 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 334 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 336 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 337 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 338 : Found opcode in column 1. (bsf)
    Warning[203] D:\CPUFAN.ASM 339 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 341 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 342 : Found opcode in column 1. (andwf)
    Warning[203] D:\CPUFAN.ASM 344 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 345 : Found opcode in column 1. (movwf)
    Error[122] D:\CPUFAN.ASM 346 : Illegal opcode (gecici)
    Warning[203] D:\CPUFAN.ASM 347 : Found opcode in column 1. (iorwf)
    Warning[203] D:\CPUFAN.ASM 349 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 350 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 352 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 353 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 354 : Found opcode in column 1. (bcf)
    Warning[203] D:\CPUFAN.ASM 355 : Found opcode in column 1. (bsf)
    Warning[203] D:\CPUFAN.ASM 357 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 358 : Found opcode in column 1. (andwf)
    Warning[203] D:\CPUFAN.ASM 360 : Found opcode in column 1. (movf)
    Warning[203] D:\CPUFAN.ASM 361 : Found opcode in column 1. (movwf)
    Error[122] D:\CPUFAN.ASM 362 : Illegal opcode (gecici)
    Warning[203] D:\CPUFAN.ASM 363 : Found opcode in column 1. (iorwf)
    Warning[203] D:\CPUFAN.ASM 365 : Found opcode in column 1. (movlw)
    Warning[203] D:\CPUFAN.ASM 366 : Found opcode in column 1. (call)
    Warning[203] D:\CPUFAN.ASM 368 : Found opcode in column 1. (return)
    Error[129] D:\CPUFAN.ASM 373 : Expected (END)



    < Bu mesaj bu kişi tarafından değiştirildi ipli jeton -- 6 Ekim 2021; 13:23:39 >
    < Bu ileti mini sürüm kullanılarak atıldı >




  • ipli jeton kullanıcısına yanıt

    Derleme imkanım olmadığı için syntax hatalarını görme şansım olmuyor maalesef.


    Kodunuzun sonlarında aşağıdaki satır 4 yerde geçiyor. Onları değiştirip denermisiniz.


    compf de "p" harfi fazla gözden kaçmış :(


    Yanlış:

    compf gecici, w ; <<--- geçici değerin bitleri tersine çevrildi ve sonuç W (akümülatöre) e yazıldı


    Doğru:

    comf gecici, w ; <<--- geçici değerin bitleri tersine çevrildi ve sonuç W (akümülatöre) e yazıldı

  • Aldığınız 5 hata mesajının 4 ünün nedeni yukarıdaki mesajda.


    Son hata mesajı ise kodunuzun son satırında end komutu eksik.



    ;-----------------------------------------------------------------------------------

    ; End of programme.

    ;-----------------------------------------------------------------------------------


    end ;<---- eksik yer

  • rafet32 kullanıcısına yanıt
    Oldu bu sefer. Şimdi simülasyona yükleyip kontrol etme zamanı.

    PIC çıkışa gönderilecek sayıyı invert yapmak

    < Bu ileti mini sürüm kullanılarak atıldı >
  • rafet32 kullanıcısına yanıt
    Anlamadığım bir başka nokta var. Fanlar her turda iki darbe yolluyor. Bu devre darbeleri sayarak fanın devrini hesaplıyor. Örneğin 1000 RPM hızla dönen bir fan bir dakikada 2000 darbe yollar. Bu şekilde dakikada 2000 darbe olacak şekilde hesplayıp pulse sinyali gönderiyorum simülasyon çalışmıyor. Ancak gerçek PIC'e yükleyip gerçek fanla deneyince oluyor.

    < Bu ileti mini sürüm kullanılarak atıldı >
  • ipli jeton kullanıcısına yanıt

    Palsi simülasyonda nasıl üretiyorsunuz/gönderiyorsunuz?

  • Diğer Soru: Siz ne veriyorsunuz, ne görüyorsunuz?

  • rafet32 kullanıcısına yanıt
    Displayde garip garip karakterler görüyorum. Gidiyor geliyor.
    Devreye sinyal jeneratörü ekliyorum. Sinyal jeneratöründen sinyalin genligini frekansını değiştirerek fan tach sinyalini taklit etmeye çalışıyorum. Ama olmuyor.
    Devre PC faninin devrini okumaya yarıyor. Fanin gönderdiği tach sinyali pic tarafından okunarak RPM bilgisine çevriliyor. İşte ben sinyal jeneratörü ile bu tach sinyalini taklit etmeye çalıştım olmadı. Normalde gerçek devrede giriş bostayken displayde 0000 yazarken, simülasyonda displayde garip garip karakterler falan çıkıyor.

    Sanırım ya sinyali tam taklit edemiyorum. Ya da proteus pic'i tam simule edemiyor.
    Zira gerçek hayatta 4511 BCD decoder ile devre sorunsuz çalışıyor. Ancak simülasyonda çalışmıyor.

    Simdi aynı devreyi katkılarınız sayesinde 7447 ve anot display ile deneyeceğim. 7447'yi yeni sipariş verdim yakın zamanda gelir. İnşallah gerçek hayatta çalışır.



    < Bu mesaj bu kişi tarafından değiştirildi ipli jeton -- 7 Ekim 2021; 9:22:34 >
    < Bu ileti mini sürüm kullanılarak atıldı >




  • rafet32 kullanıcısına yanıt

    Videosu varya izlesene :D


    < Bu ileti mobil sürüm kullanılarak atıldı >
  • Yukarıdaki konuyu ve mesaj içeriklerini kavradığınızdan emin misiniz? PIC çıkışa gönderilecek sayıyı invert yapmak 

  • 
Sayfa: 12
Sayfaya Git
Git
sonraki
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.