Re: PIC16F877_delay函示庫

作者 Edison_yu 於 2018年04月30日 08:38:18
如果你是用hi-tech picc可以參考C:\Program Files (x86)\HI-TECH Software\PICC\9.83\samples\delay


#include <htc.h> // Required to interface with delay routines

#ifndef _XTAL_FREQ
// Unless already defined assume 4MHz system frequency
// This definition is required to calibrate __delay_us() and __delay_ms()
#define _XTAL_FREQ 4000000
#endif

/** demonstration of various built-in delay mechanisms */
void main(void){
while(1){
NOP();
_delay(1000); // delay for 1000 instruction cycles
CLRWDT();
__delay_us(400); // delay for 400 microseconds
CLRWDT();
__delay_ms(2); // delay for 2 milliseconds
CLRWDT();
}
}

來自: http://www.microchip.com.tw/newbb/viewtopic.php?forum=1&topic_id=22277&post_id=78080