⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pict21c.c

📁 to light a ledfdssssssssffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
💻 C
字号:
//<pre>
// pict21c.c
//
// Implementation of the PICT21.ASM program in Easy Pic 'N
// Event counting demo
//
// In this example, TOCKI (RA4) is the external clock source - the
// clock is pulsed by a debounced external switch. In the Easy Pic 'n
// book, the switch is debounced using a half mono multivibrator. 
// The program monitors the A0 port and when it is high, it displays
// the count of the number of external pulses that went into A4
//
// Using '84 on a board (simple solderless breadboard with
// 16F84 on it) and Peter Anderson's include file with 
// port/bit definitions (defs_f84.h available at www.phanderson.com)
// Settings:
// 	4Mhz resonator (not important)
//	All Port A inputs use external pullups (resistor 
//	SIP used)
//	Port B outputs tied to a LED array (Radio Shack 
//	has 'em)
// 	Port A4 used to get inbound external clock pulse
//	Port A0 used to signal when to show the clock total - this means
//	there are two switches in use. One to pulse TOCKI and the other to
//	enable the LED bar so you can see the TMR0 value.
#case
#include <16f84.h>
#include <defs_f84.h>  // defines registers and bits
#fuses xt,nowdt,noput,noprotect
#user delay(clock=4000000)
 

void main(void)
{
   TRISA=0x1f;	// make porta inputs
   TRISB=0x00;  // make portb outputs

   setup_counters(RTCC_EXT_H_TO_L,RTCC_DIV_2);
   
   set_rtcc(0); // reset clock
   
   while(1)
   {
	if(ra0==1)
	{
          PORTB=TMR0;
	}
   }   	  
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -