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.

dsPIC<br />

®<br />

Language Tools Libraries<br />

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

3.10.3 Example of Use<br />

#define __dsPIC30F6014__<br />

#include <br />

#include<br />

int Interrupt_Count = 0 , Int_flag, count;<br />

unsigned int timer_first_edge, timer_second_edge;<br />

void __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 />

unsigned int period;<br />

Int_flag = 0;<br />

TRISDbits.TRISD0 = 0; /*Alarm output on RD0 */<br />

PORTDbits.RD0 = 1;<br />

/* Enable Timer1 Interrupt and Priority to '1' */<br />

ConfigIntCapture1(IC_INT_PRIOR_1 & IC_INT_ON);<br />

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

/* Configure the InputCapture in stop in idle mode , Timer<br />

3 as source , interrupt on capture 1, I/C on every fall<br />

edge */<br />

OpenCapture1(IC_IDLE_STOP & IC_TIMER3_SRC &<br />

IC_INT_1CAPTURE & IC_EVERY_FALL_EDGE);<br />

while(1)<br />

{<br />

while(!Int_flag); /* wait here till first capture event */<br />

Int_flag = 0;<br />

while(!Int_flag); /* wait here till next capture event */<br />

Source File: CloseOC1.c<br />

CloseOC2.c<br />

CloseOC3.c<br />

CloseOC4.c<br />

CloseOC5.c<br />

CloseOC6.c<br />

CloseOC7.c<br />

CloseOC8.c<br />

Mã số Ví dụ: CloseOC1 ();<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

DS51456B trang 132 2004 Microchip Technology Inc<br />

ConfigIntOC1<br />

ConfigIntOC2<br />

ConfigIntOC3<br />

ConfigIntOC4<br />

ConfigIntOC5<br />

ConfigIntOC6<br />

ConfigIntOC7<br />

ConfigIntOC8<br />

Mô tả: Chức năng này cấu hình ra so sánh gián đoạn.<br />

Bao gồm: outcompare.h<br />

Prototype: void ConfigIntOC1 (int config);<br />

làm mất hiệu lực ConfigIntOC2 (int config);<br />

làm mất hiệu lực ConfigIntOC3 (int config);<br />

làm mất hiệu lực ConfigIntOC4 (int config);<br />

làm mất hiệu lực ConfigIntOC5 (int config);<br />

làm mất hiệu lực ConfigIntOC6 (int config);<br />

làm mất hiệu lực ConfigIntOC7 (int config);<br />

làm mất hiệu lực ConfigIntOC8 (int config);<br />

Lập luận: config ra so sánh ngắt ưu tiên và cho phép / vô hiệu hóa<br />

thông tin theo quy định dưới đây:<br />

Ngắt bật / tắt<br />

OC_INT_ON<br />

OC_INT_OFF<br />

Ưu tiên ngắt<br />

OC_INT_PRIOR_0<br />

OC_INT_PRIOR_1

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

Saved successfully!

Ooh no, something went wrong!