Re: 用c寫中斷的問題
|
||||
---|---|---|---|---|
版主
|
1. 用 ICD2 無法計算程式或中斷的時間,建議用 MPALB SIM & Stepwatch Window 來看才會準確。
2. while(PIR2bits.TMR3IF==1 ; 改為 IF 的判斷 3. 懷疑 Timer 的中斷時間太短,導致中斷程式還沒做完,下一個中斷旗號又被設為1 了
發表於: 2007/2/14 18:02
|
|||
|
Re: 用c寫中斷的問題
|
||||
---|---|---|---|---|
高級會員
|
參照:
在date_gen()&diff_manchester()中是還有用到其他的變數,大部分的變數我的宣告成global的型態,是因為要給其他的程式來使用,不過中斷中並沒有使用到 unsigned char l; unsigned int m; 這兩個參數無關。這兩個參數本來是有在我接下來的程式中有使用到。不過目前我把其他的程式都刪除,只留下來這兩個變數與未加這兩個變數的程式來做比較,才發現這個問題的。 還有想請問版主Volatile的宣告是有什麼作用呢?因為看了work shop401的講義後,還是看不懂。
發表於: 2007/2/14 13:43
|
|||
|
Re: 用c寫中斷的問題
|
||||
---|---|---|---|---|
版主
|
參照:
不知道 date_gen( ) & diff_manchester( ) 這兩個函數做作什麼? 是否這兩個函數還有用到其它的變數。 中斷所使用的變數最好加上 Volatile 宣告,而且最好放在 Access Bank 這樣速度可以快很多。
發表於: 2007/2/14 11:32
|
|||
|
Re: 用c寫中斷的問題
|
||||
---|---|---|---|---|
高級會員
|
參照:
版主對於您所說的我還是有點不清楚,您的意思是說中斷程式運作時有被影響到的變數才會在進入中斷時被儲存,我也用mplab試過了的確變數不同在進入中斷的時間是一樣的,可是再我使用icd2模擬後,多增加幾個變數,結果就不一樣了?可是我的程式看起來在中斷副程式中,會有影響的變數應該是一樣的,為什麼出來的結果就會有差呢?由於我的中斷副程式中與時間有關,是利用中斷來擷取timer的內容值,並在中斷中判斷timer內容值的大小作為條件,如果timer的內容值過小,就會因為我的主程式中多加了幾個變數而受到影響,所以我才會認為變數的多寡會影響進入中斷的時間。可以請版主幫我看看大概是為什麼嗎
#include <p18f452.h>
發表於: 2007/2/14 10:56
|
|||
|
Re: 用c寫中斷的問題
|
||||
---|---|---|---|---|
版主
|
在其它程式所使用到的變數應與中斷無關,主要是看你的中斷程式在運作時會是否會改變其它程式的變數,如會改到就需儲存起來。一般C都會自行運儲存,當然也可以特別指定去儲存。
變數的多寡與進入中斷或副程式的時間無關,如果是使用參數傳值的話就會增加進入函數的時間這使無法避免的 (中斷函數不可以帶有參數值)。 不是很清楚 "分配變數" 的意思?
發表於: 2007/2/14 9:55
|
|||
|
用c寫中斷的問題
|
||||
---|---|---|---|---|
高級會員
|
請問用c寫的程式
在進入中斷或副程式前 如果變數宣告的愈多 進入中斷或副程式的時間就要愈久? 那麼想請問該如何有效的分配變數呢?
發表於: 2007/2/13 17:52
|
|||
|