MPLAB® C18 C 编译器函数库
MPLAB® C18 C 编译器函数库
MPLAB® C18 C 编译器函数库
- No tags were found...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
硬 件 外 设 函 数2.9.2 使 用 示 例#include #include #include #include void main( void ){int result;char str[7];// configure timer0OpenTimer0( TIMER_INT_OFF &T0_SOURCE_INT &T0_PS_1_32 );// configure USARTOpenUSART( USART_TX_INT_OFF &USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX,25 );while( 1 ){while( ! PORTBbits.RB3 ); // wait for RB3 highresult = ReadTimer0(); // read timerif( result > 0xc000 ) // exit loop if valuebreak; // is out of range}WriteTimer0( 0 );ultoa( result, str );putsUSART( str );// restart timer// convert timer to string// print stringCloseTimer0();CloseUSART();}// close modules© 2004 Microchip Technology Inc. DS51297C_CN 第 55 页