السلام عليكم ورحمة الله وبركاته
|
ما هو معناها و ما الجدوي منها مع ان البرنامج سوف يعمل من دونها
|
هذا امر خاص بالكوبيلر ولا يضر البرنامج نزعها
ما الجدوي من بدء حجز المتغيرات من عنوان 0X0C
حيث انه عنوان ريجيستر ال
PIR1
مع العلم انه من البديهي البدء من عنوان
0x20
|
المتغيرات تبدا من 0x0c في البيك 16f84 اما العنوان 0x20 فهو يخص البيك 16f628
اما فيما يخص كتابت المتغيرات فيكون عن طريقتين اما عن طريق ال EQU او عن طريق الكود المعمول في البرنامج اقصد CBLOCK الى ENDC وفيما يخص الرمز 1: فالمقصود به ان المتغير هو يحتوي على 8 bits فمثلا اذا اردنا ان نحجز 16 bits نضع 2: و 3: بالنسبة لريجيستر من حجم 32 bits ..........الخ
جربت الكود الخاص بك وماشاء الله يعمل بشكل جيد طبعا ولدي اضافة وهي اني عملت فلاشر لكن فقط باستعمال تعليمة واحدة اليك الكود
كود:
list p=16F84A
#include p16F84a.inc
ERRORLEVEL -302
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _XT_OSC
;************declare variables************
CBLOCK 0X0C
status_temp:1
w_temp:1
;-------------------------------------------
cpt:1
ENDC
;************Reset vector************
ORG 0X00
GOTO INIT
;*****************Interrupt vector**************************
ORG 0X04
;******************Interrup subrutine*****************
movwf w_temp; save W register value
swapf STATUS,w
movwf status_temp; save STATUS register value
BTFSS INTCON,T0IF; is the interrupt accured is for TIMER0 or not ?
GOTO ENDI;NO
BCF INTCON,T0IF;YES
DECF cpt,f; decrement the counter
btfss STATUS,Z; test if counter reaches the end - 1 second have just passed
GOTO ENDI;NO
MOVLW D'61';YES
MOVWF cpt; re-intiate counter value
;***********************Code Executed every second*************************
COMF PORTB
;***********************every time when leaving interrupt do this*************************
ENDI
swapf status_temp,w; get the old value of the STATUS register
movwf STATUS
swapf w_temp,f
swapf w_temp,w; get the old value of the W register
RETFIE; end of interrupt subrutine
;*****************Chip initialize**************************
INIT
; initialize ports
BSF STATUS,RP0; goto bank1
MOVLW B'00000000'
MOVWF TRISB ; portb is output
;-------------------------------------------
; initialize special function registers
movlw 0x85 ; interruption sur timer0
movwf OPTION_REG
;RBPU =1= PORTB pull-ups are disabled
;INTEDG =0= Interrupt on falling edge of RB0/INT pin
;T0CS =0= Internal instruction cycle clock (CLKOUT)
;T0SE =0= Increment on low-to-high transition on RA4/T0CKI pin
;PSA =0= Prescaler is assigned to the Timer0 module
;PS2:PS0 =101= 1 : 64 for TMR0 Rate
;-------------------------------------------
movlw 0xA0
movwf INTCON
;GIE =1= Enables all unmasked interrupts
;PEIE =0= Disables all peripheral interrupts
;TMR0IE =1= Enables the TMR0 interrupt
;INTE =0= Disables the RB0/INT external interrupt
;RBIE =0= Disables the RB port change interrupt
;TMR0IF =1= TMR0 register has overflowed (must be cleared in software)
;INTF =0= The RB0/INT external interrupt did not occur
;RBIF =0= None of the RB7:RB4 pins have changed state
;-------------------------------------------
;give ports and vaiables initiale values
BCF STATUS,RP0; return to bank0
CLRF PORTB
;-------------------------------------------
MOVLW D'61'
MOVWF cpt
;************************main program********************
START
goto START
END
هذا ودمت في رعاية الله وحفظه