30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Source File: WriteUART1.c<br />

WriteUART2.c<br />

Code Example: WriteUART1(0xFF);<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 146<br />

getsUART1<br />

getsUART2<br />

2004 Microchip Technology Inc.<br />

Description: This function reads a string of data of specified length and stores it<br />

into<br />

the buffer location specified.<br />

Include: uart.h<br />

Prototype: unsigned int getsUART1(unsigned int length,<br />

unsigned int *buffer, unsigned int<br />

uart_data_wait);<br />

unsigned int getsUART2(unsigned int length,<br />

unsigned int *buffer, unsigned int<br />

uart_data_wait);<br />

Arguments: length This is the length of the string to be received.<br />

buffer This is the pointer to the location where the data received<br />

have to be stored.<br />

uart_data_wait This is the timeout count for which the module<br />

has to wait before return.<br />

If the timeout count is ‘N’, the actual timeout<br />

would be about (19*N - 1) instruction cycles.<br />

Return Value: This function returns the number of bytes yet to be received.<br />

If the return value is ‘0’, it indicates that the complete string has been<br />

received.<br />

If the return value is nonzero, it indicates that the complete string has<br />

not been received.<br />

Remarks: None<br />

Source File: getsUART1.c<br />

getsUART2.c<br />

Code Example: Datarem = getsUART1(6, Rxdata_loc, 40);<br />

putsUART1<br />

putsUART2<br />

Description: This function writes a string of data to be transmitted into the<br />

UART<br />

transmit buffer.<br />

Cho phép đăng ký kiểm soát.<br />

Mã số Ví dụ: DisableIntU1TX;<br />

SetPriorityIntU1RX<br />

SetPriorityIntU2RX<br />

Mô tả: Điều này đặt ra ưu tiên vĩ mô cho UART nhận được gián đoạn.<br />

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

Đối số: ưu tiên<br />

Bình luận: Đây bộ vĩ mô UART Nhận ngắt bit ưu tiên của ưu tiên ngắt<br />

Kiểm soát đăng ký.<br />

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

SetPriorityIntU1TX<br />

SetPriorityIntU2TX<br />

Mô tả: Điều này đặt ra ưu tiên vĩ mô cho UART truyền gián đoạn.<br />

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

Đối số: ưu tiên<br />

Bình luận: Đây bộ vĩ mô UART Transmit Interrupt bit ưu tiên của ngắt<br />

Kiểm soát ưu tiên đăng ký.<br />

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

dsPIC Thư viện ngoại vi<br />

2004 Microchip Technology Inc DS51456B trang 149<br />

3.12.3 Ví dụ sử dụng<br />

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

# include<br />

# include<br />

/ * Dữ liệu nhận được lưu trữ trong mảng Buf * /<br />

Buf char [80];<br />

char * Receivedddata = Buf;<br />

/ * Đây là UART1 truyền ISR * /<br />

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

{<br />

IFS0bits.U1TXIF = 0;<br />

}<br />

/ * Đây là UART1 nhận ISR * /<br />

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

{<br />

IFS0bits.U1RXIF = 0;<br />

/ * Đọc bộ đệm nhận cho đến ít nhất một hoặc nhiều nhân vật có thể<br />

đọc * /<br />

trong khi (DataRdyUART1 ())

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

Saved successfully!

Ooh no, something went wrong!