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

📄 pict17c.c

📁 to light a ledfdssssssssffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
💻 C
字号:
//<pre>
// pict17c.c
//
// Implementation of the PICT17.ASM program in Easy Pic 'N
// Interrupt demo using time interval and external
// clock.
//
// In this example, TOCKI (RA4) is the external clock source - the
// interrupt is done when the clock reaches 256 hits from
// the astable multivibrator
//  which is basically a 555 timer - look it up in one of
// Forest Mim's books - Radio Shack.
// The clock will not swing over until there are 256 interrupts
// Make the 555 so it oscillates at about 50 cps and it will
// pulse the LED at about 10 second intervals.
//
// 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 A0-A3 inputs tied to ground through four switches
//	(pullups still are on them - makes it all work!)
// 	Port A4 used to get inbound external clock pulse

#case
#include <16f84.h>
#include <defs_f84.h>  // defines registers and bits
#fuses xt,nowdt,noput,noprotect

 // see page 41 of the CCS manual - this is
 // the interrupt declaration. the function that
 // follows is the interrupt service routine
#int_rtcc
void iserv(void)
{	
  	rb0=!rb0; //toggle rb0
}

void main(void)
{
   TRISA=0x1f;	// make porta inputs
   TRISB=0x00;  // make portb outputs
   rb0=1;       // turn on LED to show it is all working

   setup_counters(RTCC_EXT_H_TO_L,RTCC_DIV_2);

   enable_interrupts(INT_RTCC); // mandatory 
   set_rtcc(0); // reset clock, cause it might have value

   enable_interrupts(GLOBAL); // mandatory to start it all
   while(1);   // wait for external count to exceed 256   	  
}


⌨️ 快捷键说明

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