#include <16F628A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) #FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES MCLR //Master Clear pin enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or
#FUSES NOCPD //No EE protection
#use delay(clock=4000000)
#define LCD_DATA_PORT getenv("SFR:PORTB")
#define LCD_ENABLE_PIN PIN_A1
#define LCD_RS_PIN PIN_A0
#define LCD_RW_PIN PIN_A2
#define LCD_DATA0 PIN_B4
#define LCD_DATA1 PIN_B5
#define LCD_DATA2 PIN_B6
#define LCD_DATA3 PIN_B7
#define LCD_TYPE 2
#include <lcd.c>
long suretmp;
long sure;
#int_EXT
void EXT_isr(void)
{
suretmp=sure;
sure=0;
set_timer0(0);
}
#int_TIMER2
void TIMER2_isr(void)
{
sure++;
}
void main()
{
long devir;
int i;
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,99,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator( OSC_4MHZ );
lcd_init();
enable_interrupts(INT_EXT);
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
while(1)
{
for(i=0;i<250;i++)
{
delay_us(2);
}
lcd_gotoxy(1,1);
devir=600000/suretmp;
if((600000%suretmp)>(suretmp/2))
devir++;
printf(lcd_putc,"%Lu mS Passed",suretmp);
printf(lcd_putc,"\n%Lu RPM",devir);
}
}
Bookmarks