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.

#include <br />

#include<br />

void __attribute__((__interrupt__)) _PWMInterrupt(void)<br />

{<br />

IFS2bits.PWMIF = 0;<br />

}<br />

int main()<br />

{<br />

/* Holds the PWM interrupt configuration value*/<br />

unsigned int config;<br />

/* Holds the value to beloaded into dutycycle register */<br />

unsigned int period;<br />

/* Holds the value to be loaded into special event compare register */<br />

unsigned int sptime;<br />

/* Holds PWM configuration value */<br />

unsigned int config1;<br />

/* Holds the value be loaded into PWMCON1 register */<br />

unsigned int config2;<br />

/* Holds the value to configure the specialevent trigger<br />

postscale and dutycycle */<br />

unsigned int config3;<br />

/* The value of ‘dutycyclereg’ determines the duty cycle<br />

register(PDCx)to be written */<br />

unsigned int dutycyclereg;<br />

unsigned int dutycycle;<br />

unsigned char updatedisable;<br />

/* Configure pwm interrupt enable/disable and set interrupt<br />

priorties */<br />

config = (PWM_INT_EN & PWM_FLTA_DIS_INT & PWM_INT_PR1<br />

& PWM_FLTA_INT_PR0<br />

& PWM_FLTB_DIS_INT & PWM_FLTB_INT_PR0);<br />

ConfigIntMCPWM( config );<br />

/* Configure PWM to generate square wave of50% duty cycle */<br />

dutycyclereg = 1;<br />

dutycycle = 0x3FFF;<br />

updatedisable = 0;<br />

SetDCMCPWM(dutycyclereg,dutycycle,updatedisable);<br />

period = 0x7fff;<br />

sptime = 0x0;<br />

DS51456B trang 184<br />

2004 Microchip Technology Inc<br />

Bình luận: chức năng này sẽ xóa các bit Cờ ngắt, thiết lập các ưu tiên của ngắt<br />

chủ và nô lệ và cho phép / vô hiệu hóa ngắt.<br />

Source File: ConfigIntI2C.c<br />

Mã số Ví dụ: ConfigIntI2C (MI2C_INT_ON & MI2C_INT_PRI_3<br />

& SI2C_INT_ON & SI2C_INT_PRI_5);<br />

AckI2C<br />

Mô tả: Tạo ra tôi<br />

2<br />

Cbus Thừa nhận điều kiện.<br />

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

Prototype: void AckI2C (void);<br />

Lập luận: Không<br />

Trở lại giá trị Không<br />

Bình luận: Chức năng này tạo ra một tôi<br />

2<br />

Cbus Thừa nhận điều kiện.<br />

Source File: AckI2C.c<br />

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

DataRdyI2C<br />

Mô tả: Chức năng này cung cấp cho tình trạng trở lại cho người dùng nếu<br />

I2CRCV register chứa<br />

dữ liệu.<br />

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

Prototype: unsigned char DataRdyI2C (void);<br />

Lập luận: Không<br />

Giá trị trả lại chức năng này trả về "1" nếu có dữ liệu trong I2CRCV đăng<br />

ký; khác trở về<br />

"0" mà chỉ có dữ liệu trong I2CRCV đăng ký.<br />

Bình luận: Chức năng này xác định xem liệu có bất kỳ byte để đọc từ I2CRCV<br />

đăng ký.<br />

Source File: DataRdyI2C.c<br />

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

IdleI2C<br />

Mô tả: Đây tình trạng chức năng generatesWait cho đến khi tôi<br />

2<br />

Cbus là nhàn rỗi<br />

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

Prototype: void IdleI2C (void);<br />

Lập luận: Không

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

Saved successfully!

Ooh no, something went wrong!