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

[PIC16F84] Jak skompilować plik *.psf dla mikrokontrolera PIC16F84?

tws 22 Kwi 2004 03:44 3209 11
REKLAMA
  • #1 606618
    tws
    Poziom 11  
    Posty: 10
    Mam problem..mianowicie nie sprawia mi trudnosci zaprogramowanie PIca16f84 jezel mam do zassemblowania plik *.asm, natomiast jak moge "przerobic" plik *.psf,ktory tez jest napisany dla tego PIca? MPASM wywala mi mnostwo bledow pomimo tego,ze program jest napisany bezblednie...jakiego kompilatora powinienem uzyc?

    Przeniesiono z Programowanie Ogólne. - arnoldziq
  • REKLAMA
  • #2 607357
    elektryk
    Poziom 42  
    Posty: 11029
    Pomógł: 439
    Ocena: 241
    tws napisał:
    Mam problem..mianowicie nie sprawia mi trudnosci zaprogramowanie PIca16f84 jezel mam do zassemblowania plik *.asm, natomiast jak moge "przerobic" plik *.psf,ktory tez jest napisany dla tego PIca? MPASM wywala mi mnostwo bledow pomimo tego,ze program jest napisany bezblednie...jakiego kompilatora powinienem uzyc?
    Wrzuć pliki na forum, skoro są błędy to znaczy że jest coś źle.
  • REKLAMA
  • #3 607408
    tws
    Poziom 11  
    Posty: 10
    Oto kod programu,prawdopodobnie nie ma bledow.Nie wiem po prostu czym go przerobic do hexa-mpasm nie chce :/


    
     ;                  software: ver.6  
     ;***************** Dec. 3rd. 2002 **************************
     ;           Written by Flemming Jensen
     ; Zeroing on pwr-up
     ; Low battery indicator
     ; 
     ; No diode in series with "nF" range resistor
     ; (instead the Pic pin connected to the nF resistor
     ; is programmed as input when not used, i.e. made Hi-Z)
     ;  
     ; pF/nF/uF and up to >1F
     ; rolls over from 999pF to 1.00nF and 9.99nF to 10nF etc.  
     ; pF procedure is run twice, mean value is used. This way
     ; hum influence is reduced.     
     ; (uF range selected via a pnp, and so 1=off, 0=on)
     ;  In mF procedure, is "wait" signalled when measuring.
     ;  "ready" is shown when mF procedure has been run 4 times.
     ;  meter has to be reset by on/off when ready has been shown.
     ; p.g.a. for stor fejlvisning over 5000uF er der nu indlagt
     ; en "wait" pĺ 1500mS i uF proceduren
     ;
     ;*************************************************************
    
    
    #compiler clock = 20000   ; 20    MHz clock
    #ASM list p=16C84
    #fuse CP_OFF + PWRT_ON + WDT_OFF + XT_OSC
    
    
    
    var charout  : byte		; character output to lcd
    var flags    : byte		; boolean byte
    var lcdData  : bit 0 of flags	; T = data or F = command
    var lcdbusy  : bit 1 of flags	; lcd busy flag
    var talx         : word		; contains the cap. value
    var talx1         : word	
    var talx2         : word	
    var a            : byte		; holds number of 1000's
    var nb           : byte		; holds number of 100's
    var c            : byte		; holds number of 10's
    var d            : byte		; holds number of 1's
    var p            : byte		; prefix ( p n u m )		
    var y            : byte         ; insert dec.point ?
    var z            : word         ; open lead cap. 
    var zz           : word         ; open lead cap. 
    var tempcount    : byte         ; for delay uF range
    var delaycount   : byte         
    var q            : byte         ; holds batt. condition 
    var rdy          : byte         ; holds how many F proc.
    var proc         : byte
    
    
    alias(RB4,lcdportD4)	   ; rename port RBx to lcdportDx
    alias(RB5,lcdportD5)
    alias(RB6,lcdportD6)
    alias(RB7,lcdportD7)
    
    
    alias(RA0,lcd_rs)	   ; lcd register select
    alias(RA1,lcd_en)	   ; lcd enable
    alias(RA2,lcd_rw)	   ; lcd read/write
    
    alias(RB0,bat)             ; RB0 lo bat
    alias(RB1,range_uF)        ; range select
    alias(RB2,range_nF)
    alias(RB3,reset)           ; reset 555
    
    
    alias(RA3,trig)            ;trigger for 555
    alias(RA4,out_555)         ;output pulse from 555
    
    
    procedure(MAIN)
    InitPort		   ; set up ports
    InitLCD			   ; initialise lcd display
    reset = 1              ; reset 555 high 
    trig = 1
    clr(z)                  ; reset zeroing var
    clr(rdy)                ; rdy reset
    
    pFzero                 ; open leads cap is stored just after pwr-up
    
    
    while true
     
       clr(proc)
      pF                   ; pF procedure (000pF-9,99nF)
    
    if proc = 0 then
    begin 
      talx1 = talx              ; 2 times meas. (hum reduction)
      wait(10)
      pF
      talx2 = talx
      wait(10)
      talx = (talx1 + talx2)/2 
    end
      DoMessage
    loop 
    
    
    
    procedure(pFzero)          ; incr. talx, when 555 is high
      
    clr(y)                 ; no dec. point
    
    input(range_nF)     ; nF is made Hi-z by converting pic pin as input                  
    ;range_nF = 0       ; nF,uF deselected,(uF=pnp=off)
    range_uF = 1        ; pF is hardwired high
    
    resettrig
      
    while (b'00010000' and PortA) ;RA4 is read,(555 output) 
      inc(z)                     ;if high,increment talx
     
     if z >= 9999 then          ;if >9999pF,shift to nF
     begin
       nF
     end
    loop 
    
                            
                                ;the open 
    zz = z                      ;leads caps need to be stored twice is stored in z 
                                ; (compiler peculiarities?)
    
              
    
      
    
    procedure(pF)          ; incr. talx, when 555 is high
      
    z = zz                 ; Restoring open leads cap after having been in nF proc   
    p = 'p' 
    clr(y)                 ; no dec. point
    
    input(range_nF)                        
    ;range_nF = 0        ; nF,uF deselected,(uF=pnp=off)
    range_uF = 1        ; pF is hardwired high
    
    resettrig
      
    while (b'00010000' and PortA) ;RA4 is read,(555 output) 
    inc(talx)                     ;if high,increment talx
     
    if talx >= 9999 then          ;if >9999pF,shift to nF
    begin
       nF
    end
    loop 
    
    
    
    talx = talx-z                 ;and subtracted from result
    
    while talx > 9999             ;ensures that talx-z doesn't
      talx = talx + 1             ;go below zero
    loop
    
      
     
    if talx >= 1000 then         ;remove a decade and insert
      begin                      ;a dec.point 
       talx = talx/10
    p = 'n'                      ; n for (n)F
    y = 1                        ; insert dec.point     
    end                          ; 9999pF becomes 9,99nF
    
    
    if (b'00000001' and PortB) then
    begin
     q = 1
    end
    else                            ;RB0 testing batt. 
    begin
     q = 0
    end
    
    if q = 0 then
    begin
      lo_mess
    end  
    
        
    
    
    procedure(nF)      ; procedure nF same as pF procedure 
    p = 'n'            ; except (n)F 
    clr(y)             
    clr(z)
    proc = 1
    
    output(range_nF)                       
    range_nF = 1       ; nF range resistor selected
    range_uF = 1       ; uF=pnp=off
    
    resettrig
    
    while (b'00010000' and PortA)  
      inc(talx)
    
    if talx >= 9999 then
    begin
      uF
    end
    
    loop
    
    if talx >= 1000 then         
    begin 
      talx = talx/10
      p = 'u'
      y = 1                         
    end                         
    
    procedure(uF)          
    proc = 1
    p = 'u' 
    clr(y)             
    clr(z)
    
    input(range_nF)
    ;range_nF = 0
    range_uF = 0           ;uF(pnp=0=on)
      
    clr(talx)
    
    rst                  ; 555 reset procedure  
    trig = 1
    Wait(1500)
    trig = 0 
    delay
    trig = 1  
    
    while (b'00010000' and PortA) 
    
    clr(tempcount)                 
    
      while tempcount <= 92    ; div. by 78, caused by the long      
        inc(tempcount)         ; timing pulse in uF range
      loop                     ; calibrated for proper reading
    
    inc(talx)
     
    if talx >= 9999 then
    begin
        mF                     ; goto mF routine if talx exceeds
    end                        ; 9999
                   
    loop
    
    if talx >= 1000 then         ; same as in pF,nF
    begin 
      talx = talx/10
    
    
      p = 'm'
      y = 1                               
    end                                       
    
    
    procedure(mF)       
    inc(rdy)
    proc = 1
    
    p = 'm' 
    clr(y)
    clr(z)            
                          
    ;range_nF = 0                             
    ;range_uF = 0         ;uF range (pnp=0=on)
    
    clr(talx)
     
    rst                  ; 555 reset procedure
    waitmessage   
    trig = 1
    Wait(60000)          ; due to the long timingpulse   
    trig = 0             ; an extra long wait must be
    delay
    trig = 1             ; inserted
    
    while (b'00010000' and PortA) ;if high, increment talx  
     wait(194)           ;incr. has to be slowed down in mF 
     inc(talx)
    
    loop
    
    if talx >= 1000 then         ; same as in pF,nF
    begin 
      talx = talx/10
      p = ' '
      y = 1                               
    end                                       
    
    
    while rdy = 4
    ReadyMessage
    loop
    
    
    procedure(resettrig)
    
      
    clr(talx)
    
    rst                  ; 555 reset procedure  
    trig = 1
    Wait(100)
    trig = 0 
    delay
    trig = 1  
    
    
    
    procedure(rst)
    reset = 1
    reset = 0
    wait(1)
    reset = 1
    
    procedure(delay)
    
    clr(delaycount)                 
    while delaycount <= 1   ; Delay for trig pulse 
      inc(delaycount)        ; 
    loop  
    
    
    
    Procedure(ReadyMessage)
    lcdData = false			; sending command
    charout = b'11000000'		; cursor to 2nd line position 1
    LCDout
    lcdData = true	
    
    charout = ' '
    LCDout
    charout = ' '                   ;move display 5 spaces
    LCDout                          ;to the left
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = 'R'
    LCDout
    charout = 'e'                   
    LCDout                          
    charout = 'a'
    LCDout
    charout = 'd'
    LCDout
    charout = 'y'
    LCDout
    
    
    Procedure(WaitMessage)
    lcdData = false			; sending command
    charout = b'11000000'		; cursor to 2nd line position 1
    LCDout
    lcdData = true	
    
    charout = ' '                   ;move display 5 spaces
    LCDout                          ;to the left
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = ' '                   
    LCDout 
    charout = ' '                   
    LCDout                          
    charout = 'W'
    LCDout
    charout = 'a'
    LCDout
    charout = 'i'
    LCDout
    charout = 't'                   
    LCDout                         
    
    
    Procedure(lo_mess)
    lcdData = false			; sending command
    charout = b'11000000'		; cursor to 2nd line position 1
    LCDout
    lcdData = true	
    
    charout = ' '                   ;move display 2 spaces
    LCDout                          ;to the left
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = 'B'                   
    LCDout                          
    charout = 'A'
    LCDout
    charout = 'T'
    LCDout
    
    
    
    
    
    
    
                 
    
    procedure(doMessage)
    lcdData = false		    ; setup lcd for command receive
    charout = b'10000000'	    ; cursor to 'home' line 1 pos 1
    LCDout			    ; send to lcd
    charout = b'00000001'       ; clear display
    LCDout
    lcdData = true		    ; lcd,receive data
    
    clr(a)			    ; reset var
    clr(nb)
    clr(c)         
    clr(d)
    
    charout = ' '                   ;move display 4 spaces
    LCDout                          ;to the left
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    charout = ' '
    LCDout
    
    
     
    
    ;********** converts talx to decimals ****************
    ; by counting, how many 1000's,100's,10's and 1's
    ;*****************************************************
    
    
    
    while talx >= 1000	        ;How many 1000's 
      inc(a)			;is put in a
      talx = talx - 1000	
    loop
    if a = 0 then			;if no 1000's
    begin
      charout = ' '			;write a 'space' 
    end
    else
    begin
      charout = a + 48	        ;convert to ascii 
    end
    LCDout				; send to lcd
    while talx >= 100	        ; how many 100's
      inc(nb)			; is put in b
      talx = talx - 100			
    loop
    
    if (nb=0) and (a=0) then        ;if no 100's
    begin
      charout = ' '		        ; write a 'space'
    end
    else
    begin
      charout = nb + 48		; convert to ascii
    end
    LCDout
    if y = 1 then                   ;insert dec.point
    begin
      charout = '.'                 ;if y = 1
      LCDout
    end
    
    					
    while talx >= 10		;how many 10's 
      inc(c)		        ;is put in c
      talx = talx - 10		
    loop
    if (c=0) and (nb=0) and (a=0) then	;if no 10's
    begin
      charout = ' '				;write a space
    end
    else
    begin
      charout = c + 48		;convert to ascii 
    end
    LCDout				;send to lcd
      d = talx			;d=how many 1's
    charout = d + 48		;convert d to ascii
    LCDout				;send to lcd
    
    charout = ' '			;space
    LCDout
    charout = p			;prefix var ( p n u m )
    LCDout
    charout = 'F'			;F for farad
    LCDout
    
    
    
    procedure(InitPort)
    output(lcd_rs)      ; lcd register select output
    output(lcd_en)      ; lcd enable output
    output(lcd_rw)      ; lcd read/write output
    output(lcdportD4)   ; make port RB4 output
    output(lcdportD5)   ; make port RB5 output    
    output(lcdportD6)   ; make port RB6 output
    output(lcdportD7)   ; make port RB7 output             
    
    output(range_uF)                        ; make port output
    output(range_nF)
    output(reset)
    
    output(trig)                            ;make RA3 output
    input(out_555)                          ;make RA4 input
    input(bat)                       ;make RB0 input
    
    
    procedure(InitLCD)
    wait(15)		; Ćndring fra fřr.
    charout = b'00110000' ; 8 bit mode
    InitLCDout            ; initialise LCD
    charout = b'00110000' 
    InitLCDout            
    charout = b'00110000'
    InitLCDout
    charout = b'00100000'	; Ćndring fra fřr.
    InitLCDout
    lcdData = false       ; sending command
    charout = b'00101000' ; 4 bit, 2 lines, 5x7 font
    LCDout                ; 4 bit data transfer
    charout = b'00011000' ; cursor move, right shift
    LCDout
    charout = b'00001100' ; display on, cursor+blink off
    LCDout
    charout = b'00000100' ; entry mode
    LCDout 
    charout = b'00000001' ; clear display
    LCDout
    
    
    
    procedure(LCDout)
    busywait              ; is lcd busy
    if lcdData = false then
    begin
       lcd_rs = 0     ; 0 - instruction register
       lcd_rw = 0     ; 0 - writing to lcd
    end
    else
    begin
      lcd_rs = 1      ; 1 - data register
      lcd_rw = 0      ; 0 - writing to lcd
    end
    send4bits         ; call routine to output 4 bits
    swap(charout)     ; swap lower 4 bits
    send4bits         ; call routine to output 4 bits
    
    procedure(send4bits)
    lcdportD4 = charout AND b'00010000'    ; send 4 bits
    lcdportD5 = charout AND b'00100000'    ; send 4 bits    
    lcdportD6 = charout AND b'01000000'    ; send 4 bits    
    lcdportD7 = charout AND b'10000000'    ; send 4 bits    
    lcd_en = 1  ; Lcd enable high to low
    lcd_en = 0  ; data valid
    
    procedure(busywait)
    lcd_rw = 1        ; 1 - reading from lcd
    lcd_rs = 0        ; 0 - instruction register
    
    input(lcdportD4)  ; make port input 
    input(lcdportD5)  ; make port input 
    input(lcdportD6)  ; make port input 
    input(lcdportD7)  ; make port input 
    LCDwait
    output(lcdportD4) ; make port output
    output(lcdportD5) ; make port output
    output(lcdportD6) ; make port output
    output(lcdportD7) ; make port output
    
    procedure(LCDwait)
    lcdbusy = true
    while lcdbusy = true  ; true = lcd busy, false = ready
     lcd_en = 1            ; read data
     lcdbusy = lcdportD7   ; receive upper 4 bits first
     lcd_en = 0
     lcd_en = 1            ; not interested in lower 4
     lcd_en = 0            ; bits of status byte
    loop
    
    procedure(InitLCDout)
    wait(10)     ; wait 4 msec (no busy flag)
    lcd_rw = 0  ; 0 - writing to lcd
    lcd_rs = 0  ; 0 - instruction register
    send4bits   ; call output 4 bits 
    
    
               
  • REKLAMA
  • #4 608195
    elektryk
    Poziom 42  
    Posty: 11029
    Pomógł: 439
    Ocena: 241
    To kod w języku C i na 100% mpasm oraz mplab (bez zewnętrznych kompilatorów) tego nie ruszy.
  • #5 608322
    tws
    Poziom 11  
    Posty: 10
    wiec czym mam to skompilowac? :?: :?: :?:
  • #6 608405
    h-doc
    Poziom 27  
    Posty: 1208
    Pomógł: 57
    Ocena: 21
    elektryk - to nie C, to Pascal
  • REKLAMA
  • #7 608499
    tws
    Poziom 11  
    Posty: 10
    wlasnie w tym sek ze to chyba nie pascal ale czym to przkompilowac???
  • #8 608505
    elektryk
    Poziom 42  
    Posty: 11029
    Pomógł: 439
    Ocena: 241
    h-doc napisał:
    elektryk - to nie C, to Pascal
    Świetna podpowiedź, teraz na to wpadłem co to za język. Ani jedno ani drugie, ten język nazywa się JAL.
    :arrow: tws skąd masz ten kod? tam powinno być skomentowane co z nim zrobić.
  • #9 608743
    tws
    Poziom 11  
    Posty: 10
    mam ten programik z projektu miernika pojemnosci i nie ma nigdzie napisane jak tpo kompilowac :idea:
  • #10 609378
    elektryk
    Poziom 42  
    Posty: 11029
    Pomógł: 439
    Ocena: 241
    tws napisał:
    mam ten programik z projektu miernika pojemnosci i nie ma nigdzie napisane jak tpo kompilowac :idea:
    A skąd go wziąłeś?
  • #11 612844
    tws
    Poziom 11  
    Posty: 10
    Sciagnalem go z netu,ale nie pamietam dolkadnie skad.W jednym zipie byl szkic plytki,schemat i ten wlasnie dziwny plik....ale jak to wgrac do PICA?? do tej pory nie wiem :/
  • #12 615660
    tws
    Poziom 11  
    Posty: 10
    Dziwna sprawa z tym kodem...Sciagnalem kompilator JAL do PICa i nie dziala :/ wywala bledy juz w pierwszych liniach kodu...To chyba nie jest jezyk JAL....

Podsumowanie tematu

✨ Użytkownik ma problem z kompilacją pliku *.psf przeznaczonego dla mikrokontrolera PIC16F84. Plik ten nie jest standardowym kodem asemblerowym (*.asm) i nie jest obsługiwany przez kompilator MPASM ani MPLAB, które służą do asemblera PIC. Kod przypomina język wysokiego poziomu, początkowo podejrzewano C lub Pascala, jednak ostatecznie wskazano, że może to być język JAL (Just Another Language) dedykowany dla PIC. Próby kompilacji kodu za pomocą kompilatora JAL kończą się błędami, co sugeruje, że plik *.psf może być w innym, mniej popularnym lub niestandardowym formacie. Program pochodzi z projektu miernika pojemności, do którego dołączony był schemat i szkic płytki, ale brak jest dokumentacji dotyczącej kompilacji i programowania mikrokontrolera z tego pliku. Wskazano potrzebę znalezienia odpowiedniego narzędzia lub konwertera, który umożliwi przetworzenie pliku *.psf na kod maszynowy lub hex do wgrania do PIC16F84.
Podsumowanie AI na podstawie dyskusji. Może zawierać błędy.
REKLAMA