29.04.2015 Views

Input Capture - Microchip Taiwan

Input Capture - Microchip Taiwan

Input Capture - Microchip Taiwan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Input</strong> <strong>Capture</strong> 練 習 一 的 提 示<br />

如 何 得 到 時 間 周 期 Time Period<br />

• 兩 個 正 緣 的 時 間 即 為 輸 入 信 號 的 周 期 ,<br />

在 IC7 的 中 斷 服 務<br />

程 式 中 已 經 將 其 存 於 timer_edge[0] & timer_edge[1]<br />

while (!Int_flag);<br />

// Get two input signal edge<br />

DisableIntIC7; // Disable Interrupt of <strong>Capture</strong> 7<br />

Int_flag = 0;<br />

/* calculate time count between two capture events */<br />

If ( timer_edge[1] >= timer_edge[0])<br />

period = timer_edge[1] - timer_edge[0];<br />

else<br />

period = 65536 + timer_edge[1] - timer_edge[0];<br />

frequency= FCY/period;<br />

period = period / 14.745600 ;<br />

// Calculate the frequency<br />

// Calculate the period<br />

dsPIC Peripheral Module Training – RTC <strong>Taiwan</strong><br />

SLIDE 20

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!