30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

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

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

ReadCapture3<br />

ReadCapture4<br />

ReadCapture5<br />

ReadCapture6<br />

ReadCapture7<br />

ReadCapture8<br />

Description: This function reads all the pending Input Capture buffers.<br />

Include: InCap.h<br />

Prototype: void ReadCapture1(unsigned int *buffer);<br />

void ReadCapture2(unsigned int *buffer);<br />

void ReadCapture3(unsigned int *buffer);<br />

void ReadCapture4(unsigned int *buffer);<br />

void ReadCapture5(unsigned int *buffer);<br />

void ReadCapture6(unsigned int *buffer);<br />

void ReadCapture7(unsigned int *buffer);<br />

void ReadCapture8(unsigned int *buffer);<br />

Arguments: buffer This is the pointer to the locations where the data read from<br />

the Input Capture buffers have to be stored.<br />

Return Value: None<br />

Remarks: This function reads all the pending Input Capture buffers till the<br />

buffers<br />

are empty indicated by the ICxCON bit getting cleared.<br />

Source File: ReadCapture1.c<br />

ReadCapture2.c<br />

ReadCapture3.c<br />

ReadCapture4.c<br />

ReadCapture5.c<br />

ReadCapture6.c<br />

ReadCapture7.c<br />

ReadCapture8.c<br />

Code Example: unsigned int *buffer = 0x1900;<br />

ReadCapture1(buffer);<br />

dsPIC Peripheral Libraries<br />

2004 Microchip Technology Inc. DS51456B-page 129<br />

3.10.2 Individual Macros<br />

EnableIntIC1<br />

EnableIntIC2<br />

EnableIntIC3<br />

EnableIntIC4<br />

int timer_first_edge, timer_second_edge;<br />

khoảng trống __attribute __ ((__ interrupt__)) _IC1Interrupt (void)<br />

{<br />

Interrupt_Count ++;<br />

if (Interrupt_Count == 1)<br />

ReadCapture1 (& timer_first_edge);<br />

else if (Interrupt_Count == 2)<br />

ReadCapture1 (& timer_second_edge);<br />

Int_flag = 1;<br />

IFS0bits.IC1IF = 0;<br />

}<br />

int main (void)<br />

{<br />

giai đoạn int unsigned;<br />

Int_flag = 0;<br />

TRISDbits.TRISD0 = 0; / * Đầu ra cảnh báo về RD0 * /<br />

PORTDbits.RD0 = 1;<br />

/ * Cho phép ngắt Timer1 và ưu tiên để "1" * /<br />

ConfigIntCapture1 (IC_INT_PRIOR_1 & IC_INT_ON);<br />

T3CON = 0x8000; / * Timer 3 On * /<br />

/ * Cấu hình các InputCapture trong dừng ở chế độ nhàn rỗi, Timer<br />

3 như là nguồn, làm gián đoạn trên màn hình 1, I / C vào mỗi mùa thu<br />

cạnh * /<br />

OpenCapture1 (IC_IDLE_STOP & IC_TIMER3_SRC &<br />

IC_INT_1CAPTURE & IC_EVERY_FALL_EDGE);<br />

trong khi (1)<br />

{<br />

trong khi (Int_flag); / * Chờ đợi ở đây cho đến khi sự kiện bắt đầu * /<br />

Int_flag = 0;<br />

trong khi (Int_flag); / * Chờ đợi ở đây cho đến khi sự kiện bắt giữ tiếp theo * /<br />

/ * Tính đếm thời gian giữa hai sự kiện chụp * /<br />

thời gian = timer_second_edge - timer_first_edge;<br />

/ * Nếu tính thời gian giữa hai sự kiện chụp nhiều hơn<br />

0x200 tính, thiết lập báo động trên RD0 * /<br />

if (giai đoạn> = 0x200)<br />

{<br />

/ * Thiết lập báo động và chờ đợi đôi khi rõ ràng và báo động * /<br />

PORTDbits.RD0 = 0;<br />

trong khi (count

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

Saved successfully!

Ooh no, something went wrong!