Picproje Elektronik Sitesi

MİKRODENETLEYİCİLER => Microchip PIC => Konuyu başlatan: spawnseytan - 17 Mart 2017, 23:50:06

Başlık: pic 16f88 program atma sorunu ve çalıştırma
Gönderen: spawnseytan - 17 Mart 2017, 23:50:06
pic 16f88 datasındaki gibi bağlantıyı yapıyorum pickit3 ile atıyorum fakat 1 kere attıktan sonra sürekli hata vermeye başlıyor 'bellek bölgeleri doğru şekilde programlanamadı.' diyor
birde program olarak mplab kullanıyorum bununla programı derliyorum fakat hex yüklemeye çalışınca hata alıyorum hexi tanımıyor , sorununu çözemedim siz yardımcı olursanız memnun olurum...


;**********************************************************************
;    Filename: time.asm
;    Date:          2005/2/27
;    File Version:
;**********************************************************************

list      p=16F88 ; list directive to define processor
#include <p16F88.inc> ; processor specific variable definitions

__CONFIG   _CONFIG1,  _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_IO & _LVP_OFF & _MCLR_OFF

;***** VARIABLE DEFINITIONS
w_temp EQU     0x20 ; variable used for context saving
status_temp EQU     0x21 ; variable used for context saving

wait_data EQU 0x30 ;wait data ram
taihi EQU 0x31 ;taihi data
sec_count EQU 0x32 ;sec count
bar_count EQU 0x33 ;bar count

min_1min EQU 0x35 ;1min count
min_10min EQU 0x36 ;10min count
hour_1hour EQU 0x37 ;1hour count
hour_10hour EQU 0x38 ;10hour count
wait_data_2 EQU 0x39 ;wait data 2
key_data EQU 0x3a ;key data ram
;key_data,0  SW1 (min set)
;key_data,1  SW2 (hour set)

key_input EQU 0x3b ;key input ram
;key_input,0  SW1 (min set)
;key_input,1  SW2 (hour set)
key_cnt0 EQU 0x3c ;key_input0 repeat count
key_cnt1 EQU 0x3d ;key_input1 repeat count
h_mode EQU 0x3e ;hour mode(0=24H,1=12H)
sagyo EQU 0x3f ;12H sagyo

min_data1 EQU 0x42 ;min data 1min
min_data2 EQU 0x43 ;min data 10min
hour_data1 EQU 0x44 ;hour data 1hour
hour_data2 EQU 0x45 ;hour data 10hour
bar_data1 EQU 0x46 ;bar data kigou
hour_data3 EQU 0x47 ;hour data kigou

set_timer1 EQU 0c0h ;TMR1H set data (0.5sec)
sec_data EQU 78h ;120(78h) count
bar_data EQU 06h ;6 count

tm0_setdata EQU 0xef ;FFH-EFH=16 16*2=32usec
;**********************************************************************
ORG      0x000 ; processor reset vector
  goto    main ; go to beginning of program

;----------------------------------------------------------------------------------
ORG      0x004 ; interrupt vector location
movwf    w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register

;---------------------------------
bcf PIR1,TMR1IF
movlw set_timer1
movwf TMR1H
btfss PORTA,7
goto next_int
;---------------------------------
decfsz bar_count,1
goto next_int2
movlw bar_data
movwf bar_count
;---------------------------------
next_int2
decfsz sec_count,1
goto next_int
;---------------------------------
movlw sec_data
movwf sec_count
;--------------------------------
incf min_1min,1
movlw 0ah
subwf min_1min,0
btfss STATUS,2
goto next_int
;---------------------------------
movlw 00h
movwf min_1min
incf min_10min,1
movlw 06h
subwf min_10min,0
btfss STATUS,2
goto next_int
;---------------------------------
movlw 00h
movwf min_10min
incf hour_1hour,1
movlw 04h
subwf hour_1hour,0
btfss STATUS,2
goto next_hour2
;--------------------------------
movlw 02h
subwf hour_10hour,0
btfss STATUS,2
goto next_int
;---------------------------------
movlw 00h
movwf hour_10hour
movlw 00h
movwf hour_1hour
goto next_int
next_hour2
movlw 0ah
subwf hour_1hour,0
btfss STATUS,2
goto next_int
;---------------------------------
movlw 00h
movwf hour_1hour
incf hour_10hour,1
goto next_int
;---------------------------------


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

next_int
movf    status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf    w_temp,f
swapf  w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
;---------------------------------------------------------------------------------------
main
call osc_set
call port_set
call ad_set

movlw 0ffh
movwf PORTA
movlw 0ffh
movwf PORTB

call clear_data
call sel_clear

call timer0_set
call timer1_set
;--------------------------------------
main_loop
movlw 0ffh ;key input clear
movwf key_input
btfss PORTA,1 ;SW1 check
bcf key_input,0 ;SW1 input ari
btfss PORTA,0 ;SW2 check
bcf key_input,1 ;SW2 input ari
;--------------------------------- LED data henkan
;---------------------- MIN
movf min_1min,0
call suji_henkan1
movwf min_data1
movf min_10min,0
call suji_henkan1
movwf min_data2

btfsc h_mode,0
goto next_disp5
;---------------------- 24H
movf hour_1hour,0
call suji_henkan1
movwf hour_data1
movf hour_10hour,0
call suji_henkan2
movwf hour_data2
;---------------------- SEC
next_disp7
movf bar_count,0
call bar_henkan1
movwf bar_data1
goto next_disp6
;---------------------- 12H
next_disp5
movf hour_1hour,0
movwf sagyo
swapf hour_10hour,0
iorwf sagyo,1
movf sagyo,0
call sagyo_henkan1
call suji_henkan1
movwf hour_data3
movf sagyo,0
call sagyo_henkan2
call suji_henkan2
movwf hour_data2
movf sagyo,0
call sagyo_henkan3
call suji_henkan1
movwf hour_data1

goto next_disp7
;----------------------
next_disp6
;--------------------------------- LED disp
;----------------------- MIN
next_disp1
call sel_clear
movf min_data1,0
movwf PORTB
btfss min_data1,6
bcf PORTA,6
nop
bcf PORTA,2
nop
bcf PORTA,3
nop
bsf PORTA,4
nop
call disp_time
movf min_data2,0
movwf PORTB
btfss min_data2,6
bcf PORTA,6
nop
bsf PORTA,2
nop
bsf PORTA,3
nop
bcf PORTA,4
nop
call disp_time
btfsc h_mode,0
goto next_disp3
;------------------------ 24H
next_disp4
movf hour_data1,0
movwf PORTB
btfss hour_data1,6
bcf PORTA,6
nop
bcf PORTA,2
nop
bsf PORTA,3
nop
bcf PORTA,4
nop
call disp_time
movf hour_data2,0
movwf PORTB
btfss hour_data2,6
bcf PORTA,6
nop
bsf PORTA,2
nop
bcf PORTA,3
nop
bcf PORTA,4
nop
call disp_time
;------------------------- SEC
movf bar_data1,0
movwf PORTB
btfss bar_data1,6
bcf PORTA,6
nop
bsf PORTA,2
nop
bcf PORTA,3
nop
bsf PORTA,4
nop
call disp_time
goto next_disp2
;------------------------- 12H
next_disp3
call sel_clear
movf hour_data3,0
movwf PORTB
btfss hour_data3,6
bcf PORTA,6
nop
bcf PORTA,2
nop
bcf PORTA,3
nop
bcf PORTA,4
nop
call disp_time
goto next_disp4
;--------------------------
next_disp2

;----------------------------------SW1 check
btfss PORTA,1 ;SW1 key check
goto sw1_next
bsf key_data,0 ;SW1 off
goto sw1_end
sw1_next
btfsc key_input,0 ;SW1 input check
goto sw1_end
;------------------------
btfsc PORTA,7
goto sw1_next2
;------------------------
btfss key_data,0 ;SW1 on check
goto sw1_rep
bcf key_data,0 ;SW1 on
;------------------------
call key_cnt_set
sw1_next_r
incf min_1min,1
movlw 0ah
subwf min_1min,0
btfss STATUS,2
goto sw1_next1
movlw 00h
movwf min_1min
incf min_10min,1
movlw 06h
subwf min_10min,0
btfss STATUS,2
goto sw1_next1
movlw 00h
movwf min_10min
;-------------------------
sw1_next1
goto sw_end
;-------------------------
sw1_next2
btfss key_data,0 ;SW1 on check
goto sw_end
bcf key_data,0 ;SW1 on




goto sw_end
;------------------------
sw1_rep
decfsz key_cnt0,1
goto sw1_end
call key_cnt_set_r
goto sw1_next_r

sw1_end
;----------------------------------SW2 check
btfss PORTA,0 ;SW2 key check
goto sw2_next
bsf key_data,1 ;SW2 off
goto sw2_end
sw2_next
btfsc key_input,1 ;SW2 input check
goto sw2_end
;------------------------
btfsc PORTA,7
goto sw2_next2
;------------------------
btfss key_data,1 ;SW2 on check
goto sw2_rep
bcf key_data,1 ;SW2 on
;------------------------
call key_cnt_set
sw2_next_r
incf hour_1hour,1
movlw 04h
subwf hour_1hour,0
btfss STATUS,2
goto sw2_next3
movlw 02h
subwf hour_10hour,0
btfss STATUS,2
goto sw2_next1
movlw 00h
movwf hour_10hour
movlw 00h
movwf hour_1hour
goto sw2_next1
sw2_next3
movlw 0ah
subwf hour_1hour,0
btfss STATUS,2
goto sw2_next1
movlw 00h
movwf hour_1hour
incf hour_10hour,1
;-------------------------
sw2_next1
goto sw_end
;-------------------------
sw2_next2
btfss key_data,1 ;SW2 on check
goto sw_end
bcf key_data,1 ;SW2 on

btfsc h_mode,0
goto sw2_next4
bsf h_mode,0
goto sw_end
sw2_next4
bcf h_mode,0
goto sw_end
;-------------------------
sw2_rep
decfsz key_cnt1,1
goto sw2_end
call key_cnt_set_r
goto sw2_next_r

sw2_end
sw_end
btfsc PORTA,7
goto sw_end2
movlw bar_data
movwf bar_count
movlw sec_data
movwf sec_count

sw_end2
;---------------------------------------
goto main_loop
;-------------------------------------------------------------------------------
wait_20
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
return
;-------------------------------------------------------------------------------
wait_12
movlw 2h
movwf wait_data_2
wait_12_2
call wait_1
decfsz wait_data_2,1
goto wait_12_2
return

wait_11
movlw 1h
movwf wait_data_2
wait_11_2
call wait_1
decfsz wait_data_2,1
goto wait_11_2
return

wait_10
movlw 3h
movwf wait_data_2
wait_10_2
call wait_1
decfsz wait_data_2,1
goto wait_10_2
return

wait_0
movlw 0ffh
movwf wait_data
goto wait_2
wait_1
movlw 0ffh
movwf wait_data
wait_2
nop
decfsz wait_data,1
goto wait_2
return
;-----------------------------------------------------------------------------
disp_time
btfsc PORTA,5
goto disp_time2
call wait_10
call sel_clear
return
disp_time2
call wait_11
call sel_clear
call wait_12
return
;------------------------------------------------------------------------------
key_cnt_set_r
movlw 0ah
goto key_cnt_set2
key_cnt_set
movlw 030h
key_cnt_set2
movwf key_cnt0
movwf key_cnt1
return
;------------------------------------------------------------------------------
clear_data
movlw bar_data
movwf bar_count
movlw sec_data
movwf sec_count
movlw 00h
movwf min_1min
movwf min_10min
movwf hour_1hour
movwf hour_10hour
movwf h_mode
return
;------------------------------------------------------------------------------
sel_clear
bsf PORTA,2
nop
bsf PORTA,3
nop
bsf PORTA,4
nop
bsf PORTA,6
nop
return
;------------------------------------------------------------------------------
suji_henkan1
movwf taihi
movlw low(suji_table1)
addwf taihi,1
movlw high(suji_table1)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
suji_table1
;-----------
retlw 40h ;0
retlw 79h ;1
retlw 24h ;2
retlw 30h ;3
retlw 19h ;4
retlw 12h ;5
retlw 02h ;6
retlw 58h ;7
retlw 00h ;8
retlw 10h ;9
retlw 08h ;a
retlw 0ch ;b
retlw 00h ;c
retlw 00h ;d
retlw 00h ;e
retlw 00h ;f
;------------------------------------------------------------------------------
suji_henkan2
movwf taihi
movlw low(suji_table2)
addwf taihi,1
movlw high(suji_table2)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
suji_table2
;-----------
retlw 7fh ;0
retlw 79h ;1
retlw 24h ;2
retlw 30h ;3
retlw 19h ;4
retlw 12h ;5
retlw 02h ;6
retlw 58h ;7
retlw 00h ;8
retlw 10h ;9
retlw 08h ;a
retlw 0ch ;b
retlw 00h ;c
retlw 00h ;d
retlw 00h ;e
retlw 00h ;f
;------------------------------------------------------------------------------
bar_henkan1
movwf taihi
movlw low(bar_table1)
addwf taihi,1
movlw high(bar_table1)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
bar_table1
;-----------
retlw 3fh ;0 dummy
retlw 3fh ;1
retlw 7fh ;2
retlw 3fh ;3
retlw 7fh ;4
retlw 3fh ;5
retlw 7fh ;6
;------------------------------------------------------------------------------
sagyo_henkan1
movwf taihi
movlw low(sagyo_table1)
addwf taihi,1
movlw high(sagyo_table1)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
sagyo_table1
;-----------
retlw 0ah ;00
retlw 0ah ;01
retlw 0ah ;02
retlw 0ah ;03
retlw 0ah ;04
retlw 0ah ;05
retlw 0ah ;06
retlw 0ah ;07
retlw 0ah ;08
retlw 0ah ;09
retlw 00h ;0a
retlw 00h ;0b
retlw 00h ;0c
retlw 00h ;0d
retlw 00h ;0e
retlw 00h ;0f
retlw 0ah ;10
retlw 0ah ;11
retlw 0bh ;12
retlw 0bh ;13
retlw 0bh ;14
retlw 0bh ;15
retlw 0bh ;16
retlw 0bh ;17
retlw 0bh ;18
retlw 0bh ;19
retlw 00h ;1a
retlw 00h ;1b
retlw 00h ;1c
retlw 00h ;1d
retlw 00h ;1e
retlw 00h ;1f
retlw 0bh ;20
retlw 0bh ;21
retlw 0bh ;22
retlw 0bh ;23
;------------------------------------------------------------------------------
sagyo_henkan2
movwf taihi
movlw low(sagyo_table2)
addwf taihi,1
movlw high(sagyo_table2)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
sagyo_table2
;-----------
retlw 01h ;00
retlw 00h ;01
retlw 00h ;02
retlw 00h ;03
retlw 00h ;04
retlw 00h ;05
retlw 00h ;06
retlw 00h ;07
retlw 00h ;08
retlw 00h ;09
retlw 00h ;0a
retlw 00h ;0b
retlw 00h ;0c
retlw 00h ;0d
retlw 00h ;0e
retlw 00h ;0f
retlw 01h ;10
retlw 01h ;11
retlw 01h ;12
retlw 00h ;13
retlw 00h ;14
retlw 00h ;15
retlw 00h ;16
retlw 00h ;17
retlw 00h ;18
retlw 00h ;19
retlw 00h ;1a
retlw 00h ;1b
retlw 00h ;1c
retlw 00h ;1d
retlw 00h ;1e
retlw 00h ;1f
retlw 00h ;20
retlw 00h ;21
retlw 01h ;22
retlw 01h ;23
;------------------------------------------------------------------------------
sagyo_henkan3
movwf taihi
movlw low(sagyo_table3)
addwf taihi,1
movlw high(sagyo_table3)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
sagyo_table3
;-----------
retlw 02h ;00
retlw 01h ;01
retlw 02h ;02
retlw 03h ;03
retlw 04h ;04
retlw 05h ;05
retlw 06h ;06
retlw 07h ;07
retlw 08h ;08
retlw 09h ;09
retlw 00h ;0a
retlw 00h ;0b
retlw 00h ;0c
retlw 00h ;0d
retlw 00h ;0e
retlw 00h ;0f
retlw 00h ;10
retlw 01h ;11
retlw 02h ;12
retlw 01h ;13
retlw 02h ;14
retlw 03h ;15
retlw 04h ;16
retlw 05h ;17
retlw 06h ;18
retlw 07h ;19
retlw 00h ;1a
retlw 00h ;1b
retlw 00h ;1c
retlw 00h ;1d
retlw 00h ;1e
retlw 00h ;1f
retlw 08h ;20
retlw 09h ;21
retlw 00h ;22
retlw 01h ;23

;------------------------------------------------------------------------------
banksel_0
bcf STATUS,RP0
nop
bcf STATUS,RP1
nop
return
banksel_1
bsf STATUS,RP0
nop
bcf STATUS,RP1
nop
return
banksel_2
bcf STATUS,RP0
nop
bsf STATUS,RP1
nop
return
banksel_3
bsf STATUS,RP0
nop
bsf STATUS,RP1
nop
return
;------------------------------------------------------------------------------
osc_set
call banksel_1
;(0)NC
;(110)IRCF2-IRCF0
;(0)OSTS
;(1)IOFS
;(00)SCS
movlw 64h
movwf OSCCON
call banksel_0
return
;-------------------------------------------------------------------------------
port_set ;RA2,RA3,RA4,RA6(OUT)
;RA0,RA1,RA5,RA7(IN)
;RB0,RB1,RB2,RB3,RA4,RA5(OUT)
;RB6,RB7(IN)
call banksel_1
clrf TRISA
bsf TRISA,0
nop
bsf TRISA,1
nop
bsf TRISA,5
nop
bsf TRISA,7
nop
clrf TRISB
bsf TRISB,6
nop
bsf TRISB,7
nop
call banksel_0
return
;------------------------------------------------------------------------------
ad_set
;(01)ADCS1,ADCS0
;(000)CHS2,CHS1,CHS0
;(0)GO/DONE
;(0)NC
;(0)ADON
movlw 40h
movwf ADCON0
call banksel_1
;(0)ADFM
;(1)ADCS2
;(00)VCFG1,VCFG0
;(0000)
movlw 040h
movwf ADCON1
;(0)NC
;(0000000)ANS6-ANS0
movlw 00h
movwf ANSEL
call banksel_0
return
;-------------------------------------------------------------------------------
timer0_set

bsf STATUS,RP0
movlw 086h ;(1)PORTB NOT PULLUP
;(0)INTEDG
;(0)TOCS
;(0)TOSE
;(0)PSA
;(110)1/128
movwf OPTION_REG
bcf STATUS,RP0

movlw tm0_setdata
movwf TMR0
bcf INTCON,TMR0IE
bcf INTCON,GIE
return
;------------------------------------------------------------------------------
timer1_set
;(0)NC
;(0)T1RUN
;(00)T1CKPS1,T1CKPS0
;(1)T1OSCEN
;(0)T1SYNC
;(1)TMR1CS
;(1)TMR1ON
movlw 0bh
movwf T1CON
movlw set_timer1
movwf TMR1H
movlw 00h
movwf TMR1L

call banksel_1
bsf PIE1,TMR1IE
call banksel_0
bsf INTCON,PEIE
bsf INTCON,GIE
return
;-------------------------------------------------------------------------------

end                     ; directive 'end of program'

Başlık: Ynt: pic 16f88 program atma sorunu ve çalıştırma , yardım edin
Gönderen: spawnseytan - 19 Mart 2017, 00:15:40
anlıyorum birdahaki sefere kod bölümünü kullanırım ..
konu ile ilgili problemim konusunda yardımcı olabileceğiniz bir nokta var mı?
Başlık: Ynt: pic 16f88 program atma sorunu ve çalıştırma
Gönderen: RaMu - 19 Mart 2017, 22:13:06
Pici devre üzerinde programlıyorsan,
devrene enerji ver,
pic beslemesi olsun yani.
Devre pickit üzerinden beslenmeye çalışırsa
ve fazla akım çekerse,
program atarken problem olur.


Daha bir çok başka problem var tabiki.
Başlık: Ynt: pic 16f88 program atma sorunu ve çalıştırma
Gönderen: spawnseytan - 22 Mart 2017, 20:34:34
senin dediğinide yaptım ama olmadı , pici ben ayrı olarak besliyorum ilk yüklememde pice yazabiliyorum ama devamıda yazamıyorum . benim bildiğim kadarıyla istediğin kadar üzerine yazzman gerekiyor ama ben neden yapamıyorum neresi eksik kalıyor bilmiyorum. program devre şekli pickit3 ün bağlantı bacaklarıyla picin bağlantı bacakları tutuyor , besleme pickit 3 ten alıyor ve yeterlide , sorun için sizden yardım bekliyorum ...