Re: 請問跑馬燈設計的問題
|
||||
---|---|---|---|---|
資深會員
|
ICD2設中斷..是點2下跑出一個紅色圈圈B ?
有個問題就是一直在Null_Loop 那... 沒辦法跳到中斷向量....
發表於: 2006/7/1 8:44
|
|||
|
Re: 請問跑馬燈設計的問題
|
||||
---|---|---|---|---|
高級會員
|
用ICD2設一下中斷跑幾下應該就知道問題了
如果沒有,用軟體模擬應該也跑的出來 自己抓會比較快,也比較有收穫
發表於: 2006/6/30 17:45
|
|||
微電腦自動控制設計,產品製造
才疏學淺,若有錯誤敬請指正 |
||||
|
請問跑馬燈設計的問題
|
||||
---|---|---|---|---|
資深會員
|
一直都弄不出來,不知道程式那裡寫錯,麻煩幫忙看下,謝謝
;******************************************** ;設計一個0.5秒讓 PORTD 的 LED 自動加一的程式 ;******************************************** list p=18f4431 include <p18f4431.inc> ; TMR1_VAL EQU .39062 ; Timer0 設定為 500ms 中斷一次 ;******************************************** ; RESET Vector @ 0x0000 ;******************************************** org 0x0000 ; bra Main ; org 0x0008 ; bra Hi_ISRs ; ;******************************************** ;The Main Program start from Here !! ;******************************************** org 0x0020 Main: call Init_IO call Init_Timer0 ; bsf RCON,IPEN ; 中斷向量,Enable bsf INTCON,GIEH ; 高優先中斷權,Enable ; Null_Loop goto Null_Loop ; 迴圈,等待TMRO溢位,跳到中斷向量 ; ;******************************************** ;Initial the PORTD for the output port ;******************************************** Init_IO: clrf TRISD clrf PORTD return ;******************************************** ;Initial Timer0 as a 500ms Timer ;******************************************** Init_Timer0: movlw B'10000101' movwf T0CON ; 使用16-bit mode , Prescaler = 1:64 ; 使用20MHZ,Timer0 On movlw (.65536-TMR1_VAL)/.256 movwf TMR0H movlw (.65536-TMR1_VAL)%.256 movwf TMR0L ; bsf INTCON2,TMR0IP ; 設定 Timer0 高優先中斷向量 bcf INTCON,TMR0IF ; 清除 Timer0 溢位中斷標誌 bsf INTCON,TMR0IE ; Timer0 中斷,Enable ; return ;******************************************** ;****ISRs() : 中斷服務程式 ;******************************************** Hi_ISRs bcf INTCON,TMR0IF ; 清除 Timer0 溢位中斷標誌 ; movlw (.65536-TMR1_VAL)/.256 movwf TMR0H movlw (.65536-TMR1_VAL)%.256 movwf TMR0L incf PORTD,F ; PORTD = PORTD + 1; retfie FAST END
發表於: 2006/6/30 16:48
|
|||
|