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

論壇索引


Board index » All Posts (fannky)




Re: Questions for comparator module?
#1
新會員
新會員


請說明:
1. 是用那一型MCU?
2. 有無clear A/D channel?

發表於: 2005/12/13 15:58
頂部


Re: Questions for comparator module?
#2
新會員
新會員


請說明:
1. 是用那一型MCU?
2. 有無clear A/D channel?

發表於: 2005/12/13 15:57
頂部


Re: p16f877, 關TMR1中斷使用問題
#3
新會員
新會員


謝謝指導。仍無法找到問題所在。
此為範例程式
因配合bootloader,所以:
reset vector 設在0x10, 而interrupt vector設在0x14
其中macro是將W_reg及STATUS狀態先暫存,待程式執行完後
再回存。
在interrupt子程式中只有T1_Int有程式,作為測式TMR1 Interrupt用。

請再次不吝指教。

list p=16f877,r=dec
#include "p16f877.inc"
#include "mymacro.mac"

;******* Define variables here *************

W_Temp equ 0x21
STATUS_Temp equ 0x22
Counter equ 0x23


;******* Start and Interrupt vector *************

org 0x10 ; reset vector
goto Main_Program

org 0x14
goto Int_Service ; interrupt vector

;******* Main Process 'Start' *******************

Main_Program:
call Initial

Main_Program_End:
goto Main_Program_End

;******* Main Process 'End' *********************
;------------------------------------------------
;******* Program Test 'Start' *******************

Program_Test:

Program_Test_End:
return

;******* Program Test 'End' *********************
;------------------------------------------------
;******* Function Call 'Start' ******************

Function_Test:

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

Time_Ini:
banksel TMR1H
movlw 0xff
movwf TMR1H
movlw 0xee
movwf TMR1L
return

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

Function_Test_End:
retlw 0

;******* Function Call 'End' ********************
;------------------------------------------------
;******* Initial System 'Start' *****************

Initial:
banksel TRISD
clrf TRISD
banksel PORTD
movlw 0x01
movwf PORTD
movlw 0x00
movwf T1CON
clrf Counter
call Time_Ini
banksel INTCON
bsf INTCON, GIE
bsf INTCON, PEIE
banksel PIE1
bsf PIE1,TMR1IE
banksel T1CON
bsf T1CON,TMR1ON

Initial_End:
return

;******* Initial System 'End' *******************
;------------------------------------------------
;******* Interrupt Service 'Start' **************

Int_Service:
PUSH_W_STATUS W_Temp,STATUS_Temp ;Macro

;******* Check interrupt source **************

btfsc INTCON,INTF
goto EX_Int
btfsc INTCON,T0IF
goto T0_Int
btfsc INTCON,RBIF
goto RB_Int

; peripheral 1 interrupt *********************

banksel PIR1
btfsc PIR1,TMR1IF
goto T1_Int
btfsc PIR1,TMR2IF
goto T2_Int
btfsc PIR1,CCP1IF
goto CCP1_Int
btfsc PIR1,SSPIF
goto SSP_Int
btfsc PIR1,TXIF
goto TX_Int
btfsc PIR1,RCIF
goto RC_Int
btfsc PIR1,ADIF
goto AD_Int
btfsc PIR1,PSPIF
goto PSP_Int

; peripheral 2 interrupt *********************

btfsc PIR2,CCP2IF
goto CCP2_Int
btfsc PIR2,BCLIF
goto BCL_Int
btfsc PIR2,EEIF
goto EE_Int

;---------------------------------------------
; Interrupt Service routine ******************

EX_Int:
;******* add your code here ******************

;---------------------------------------------
bcf INTCON,INTF
goto Int_Service_End

T0_Int:
;******* add your code here ******************


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

bcf INTCON,T0IF
goto Int_Service_End

RB_Int:
;******* add your code here ******************

;---------------------------------------------
bcf INTCON,RBIF
goto Int_Service_End

T1_Int:
;******* add your code here ******************

call Time_Ini
incf Counter,F
movf Counter,W
sublw 0xa4
btfss STATUS,Z
goto T1_Int_End
bcf STATUS,C
rlf PORTD,W
rlf PORTD,F
clrf Counter

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

T1_Int_End:
bcf PIR1,TMR1IF
goto Int_Service_End

T2_Int:
;******* add your code here ******************


;---------------------------------------------
bcf PIR1,TMR2IF
goto Int_Service_End

CCP1_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR1,CCP1IF
goto Int_Service_End

SSP_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR1,SSPIF
goto Int_Service_End

TX_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR1,TXIF
goto Int_Service_End

RC_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR1,RCIF
goto Int_Service_End

AD_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR1,ADIF
goto Int_Service_End

PSP_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR1,PSPIF
goto Int_Service_End

CCP2_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR2,CCP2IF
goto Int_Service_End

BCL_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR2,BCLIF
goto Int_Service_End

EE_Int:
;******* add your code here ******************

;---------------------------------------------
bcf PIR2,EEIF
goto Int_Service_End

;---------------------------------------------
POP_W_STATUS W_Temp,STATUS_Temp ;Macro

Int_Service_End:
retfie

;******* Interrupt Service 'End' ****************
;------------------------------------------------

end

發表於: 2005/1/11 14:30
頂部


p16f877, 關TMR1中斷使用問題
#4
新會員
新會員


小弟最近才接觸PIC16F877。
那位先進有空時請不吝指導下列問題:

在設定Timer1 interrupt時遇到下列問題:
當Timer1 overflow時程式會直接回到 reset vector而不是到
interrupt vector。
小弟有再三確認已設定:
movlw 0x00
movwf T1CON
INTCON GIE, PEIE, 設為1
PIE1 TMR1IE 設為1
最後
t1con TMR1ON, 設為1。
以上。不知問題是發生在那裡。

發表於: 2005/1/11 12:35
頂部






:::

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... ]

教育訓練中心

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