• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 請問各位前輩有關16f687的問題
#2
高級會員
高級會員


查看用戶資訊
你設
CLRF WPUA ;disabled pull-up
那你有外部PULL-HIGH嗎?

而且你有設
BANKSEL IOCA
MOVLW B'00001001' ;#B'00000000'
MOVWF IOCA
那是INTERRUPT-ON-CHANGE

你沒用到中斷
不需設IOCA

你把WPUA,3設為1試試看!

發表於: 2008/8/13 15:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問各位前輩有關16f687的問題
#1
新會員
新會員


查看用戶資訊
不好意思,因為我要利用RA3當作INPUT來判斷燈是否會亮
當RA3=LOW時燈就會亮,RA3=HIGH時燈就不會亮
可是我利用示波器來觀看結果,當RA3=HIGH時燈卻亮起來
那我也檢查過程式覺得沒有問題,所以來此問各位前輩哪裡有問題,以下是程式碼:

; ===================================================================
; Macros
SelBank0 macro
BCF STATUS,RP1
BCF STATUS,RP0
endm
SelBank1 macro
BCF STATUS,RP1
BSF STATUS,RP0
endm
SelBank2 macro
BSF STATUS,RP1
BCF STATUS,RP0
endm
SelBank3 macro
BSF STATUS,RP1
BSF STATUS,RP0
endm
;**********************************************************************
ORG 0x000 ; processor reset vector
GOTO MAIN ; go to beginning of program
ORG 0X004
GOTO INTERRUPT

;-----------------------------------------------
; PORTA SETTING
;------------------------------------------------
SelBank0
BANKSEL PORTA
MOVLW B'00011001' ;#B'00011001'
MOVWF PORTA
SelBank1
MOVLW B'00101111' ;#B'00101111'
MOVWF TRISA

SelBank2 ;Bank 2
CLRF ANSEL ;digital I/O
CLRF WPUA ;disabled pull-up
BANKSEL IOCA
MOVLW B'00001001' ;#B'00000000'
MOVWF IOCA

;---------------------------------------------
; PORTC SETTING
;---------------------------------------------
SelBank0
MOVLW B'00010000' ;#B'00000000'
MOVWF PORTC
SelBank1
MOVLW B'11000000' ;#B'00001111'
MOVWF TRISC

MAIN
DisableInterrupts
CALL INITIAL
EnableInterrupts
CALL VARIABLE_INITIAL
DELAY
MOVLW .150
CALL Delay_Process
DELAY1
MOVLW .0
XORWF Delay10msCountReg,W
BTFSS STATUS,Z
GOTO DELAY1
GOTO DELAY
;----------------------------------------------------------
INTERRUPT
T0_ISR
; do Timer 0 stuff here
CALL T0_ISR_Process
SelBank0
MOVLW .216
MOVWF TMR0
BCF INTCON,T0IF;
GOTO ISR_DONE

;------------------------------------------------------------
; TO_ISR_PROCESS
;-----------------------------------------------------------
T0_ISR_Process
DECF Delay10msCountReg,F
CALL CheckAudio_Process
RETURN

;-----------------------------------------------------------------
; FINISH THE INTERRUPTION
;------------------------------------------------------------------
ISR_DONE
;finished with the ISR, return
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 interru

;--------------------------------------------------------------
CheckAudio_Process
SelBank0
BTFSC PORTA,RA3 -->初始為HIGH
GOTO CheckOffAudio_Process
CLRF NoAudio10msCountReg
CLRF NoAudio1sCountReg
BSF PORTC,RC0--->燈卻亮起來
BSF AudioFlag1Reg,AudioDetectF1
; GOTO POWERON
RETURN
END

發表於: 2008/8/13 14:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------