newpic2009
02-04-2009, 12:31 PM
hi,
mình viết 1 đoạn để xuất ra GP1, GP2, GP5 theo xung nhu sau :
GP5 __i-----------------------------------------
GP1 __i--i____i--i____i--i____
GP2 _____i--i____i--i____i--i____
và lập lại như trên, code mình viết như sau,
;************************************************* ***
list p=12F508 ; list directive to define processor
#include <p12F508.inc> ; processor specific variable definitions
__CONFIG _MCLRE_ON & _CP_ON & _WDT_OFF & _IntRC_OSC
;***** VARIABLE DEFINITIONS
UDATA
count1 res 1 ; delay loop counters
count2 res 1
dc3 res 1
;************************************************* *********************
RESET CODE 0x1FF ; processor reset vector
res 1 ; holds movlw with factory RC cal value
; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.
MAIN code 0x000
movwf OSCCAL
movlw b'011000' ; configure GP0,GP1,GP2,GP5 as output
tris GPIO
start
movlw b'000111'
movwf GPIO
bsf GPIO,5 ;GP5 = 1
;form1 wareform
begin
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
nop
goto begin
END
;*****************************************
nhờ các bác xem giúp sao GP1 thì xuất ra đúng mà GP2 lại không xuất ra ?
và sao nó không lập lại liên tục, chỉ xuất lập lại một số lần là dừng lại ?
thanks,
mình viết 1 đoạn để xuất ra GP1, GP2, GP5 theo xung nhu sau :
GP5 __i-----------------------------------------
GP1 __i--i____i--i____i--i____
GP2 _____i--i____i--i____i--i____
và lập lại như trên, code mình viết như sau,
;************************************************* ***
list p=12F508 ; list directive to define processor
#include <p12F508.inc> ; processor specific variable definitions
__CONFIG _MCLRE_ON & _CP_ON & _WDT_OFF & _IntRC_OSC
;***** VARIABLE DEFINITIONS
UDATA
count1 res 1 ; delay loop counters
count2 res 1
dc3 res 1
;************************************************* *********************
RESET CODE 0x1FF ; processor reset vector
res 1 ; holds movlw with factory RC cal value
; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.
MAIN code 0x000
movwf OSCCAL
movlw b'011000' ; configure GP0,GP1,GP2,GP5 as output
tris GPIO
start
movlw b'000111'
movwf GPIO
bsf GPIO,5 ;GP5 = 1
;form1 wareform
begin
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
bsf GPIO,1
nop
bcf GPIO,2
nop
nop
nop
bsf GPIO,2
nop
bcf GPIO,1
nop
nop
nop
nop
goto begin
END
;*****************************************
nhờ các bác xem giúp sao GP1 thì xuất ra đúng mà GP2 lại không xuất ra ?
và sao nó không lập lại liên tục, chỉ xuất lập lại một số lần là dừng lại ?
thanks,