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.

SetPulseOC4<br />

SetPulseOC5<br />

SetPulseOC6<br />

SetPulseOC7<br />

SetPulseOC8<br />

Description: This function configures the Output Compare main and secondary<br />

registers (OCxR and OCxRS ) whenthe module is not in PWM mode.<br />

Include: outcompare.h<br />

Prototype: void SetPulseOC1(unsigned int pulse_start,<br />

unsigned int pulse_stop);<br />

void SetPulseOC2(unsigned int pulse_start,<br />

unsigned int pulse_stop);<br />

void SetPulseOC3(unsigned int pulse_start,<br />

u nsigned int pulse_stop);<br />

void SetPulseOC4(unsigned int pulse_start,<br />

unsigned int pulse_stop);<br />

void SetPulseOC5(unsigned int pulse_start,<br />

unsigned int pulse_stop);<br />

void SetPulseOC6(unsigned int pulse_start,<br />

unsigned int pulse_stop);<br />

void SetPulseOC7(unsigned int pulse_start,<br />

unsigned int pulse_stop);<br />

void SetPulseOC8(unsigned int pulse_start,<br />

unsigned int pulse_stop);<br />

Arguments: pulse_start This is the value to be stored into Output Compare<br />

Main register (OCxR).<br />

pulse_stop This is the value to be stored into Output Compare<br />

Secondary register (OCxRS).<br />

Return Value: None<br />

Remarks: The Output Compare duty cycle registers (OCxR and OCxRS) will be<br />

configured with new values only ifthe module is not in PWM mode.<br />

Source File: SetPulseOC1.c<br />

SetPulseOC2.c<br />

SetPulseOC3.c<br />

SetPulseOC4.c<br />

SetPulseOC5.c<br />

SetPulseOC6.c<br />

SetPulseOC7.c<br />

SetPulseOC8.c<br />

# xác định __dsPIC30F6014__<br />

# include<br />

# include<br />

/ * Đây là ISR tương ứng với OC1 ngắt * /<br />

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

{<br />

IFS0bits.OC1IF = 0;<br />

}<br />

int main (void)<br />

{<br />

/ * Giữ giá trị mà tại đó OCX Pin được điều khiển * cao /<br />

int pulse_start;<br />

/ * Giữ giá trị mà tại đó OCX Pin được điều khiển * thấp /<br />

int pulse_stop;<br />

/ * Tắt OC1 mô-đun * /<br />

CloseOC1 ();<br />

/ * Cấu hình đầu ra compare1 ngắt * /<br />

ConfigIntOC1 (OC_INT_OFF & OC_INT_PRIOR_5);<br />

/ * Cấu hình OC1 mô-đun cho yêu cầu độ rộng xung * /<br />

pulse_start = 0x40;<br />

pulse_stop = 0x60;<br />

PR3 = 0x80;<br />

PR1 = 0xffff;<br />

TMR1 = 0x0000;<br />

T3CON = 0x8000;<br />

T1CON = 0x8000;<br />

/ * Cấu hình đầu ra so sánh các mô-đun để 'khởi OCX pin<br />

thấp và tạo ra liên tục pulse'mode * /<br />

OpenOC1 (OC_IDLE_CON & OC_TIMER3_SRC &<br />

OC_CONTINUE_PULSE,<br />

pulse_stop, pulse_start);<br />

/ * Tạo xung liên tục cho đến khi đạt TMR1 0xff00 * /<br />

trong khi (TMR1

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

Saved successfully!

Ooh no, something went wrong!