29.04.2015 Views

Input Capture - Microchip Taiwan

Input Capture - Microchip Taiwan

Input Capture - Microchip Taiwan

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

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

• 宣 告 一 個 陣 列 timer _ edge[2] 來 存 放 capture 事 件 發 生 當 時<br />

的 Timer 值<br />

• 在 <strong>Input</strong> <strong>Capture</strong> 7 (IC7) Interrupt Function 可 以 連 續 對 IC7<br />

做 2 次 的 讀 取<br />

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

void _ISR _IC7Interrupt(void)<br />

// Interrupt Function for the IC7<br />

{<br />

Read<strong>Capture</strong>7( &timer_edge[0]); // Read Timer count from FIFO 0<br />

Read<strong>Capture</strong>7( &timer_edge[1]); // Read Timer count from FIFO 1<br />

Int_flag = 1;<br />

// Set IC7 process Flag<br />

IFS1bits.IC7IF = 0;<br />

// Clear the IC7 interrupt flag<br />

}<br />

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

SLIDE 19

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

Saved successfully!

Ooh no, something went wrong!