I tried to make a tachometer using RB0 and Timer1 interrupt. I simulated on ISIS with a Pulse generator... I choose 200mS from pulse generator, but on LCD it shows always different values. I cannot find the reason. Pls help...
DEFINE LCD_DREG PORTB' LCD Data Port
DEFINE LCD_DBIT 4 ' LCD Data Bit
DEFINE LCD_RSREG PORTA ' LCD RS Port
DEFINE LCD_RSBIT 0 ' LCD RS Bit
DEFINE LCD_EREG PORTA ' LCD Enable Port
DEFINE LCD_EBIT 1 'LCD Enable Bit
DEFINE LCD_BITS 4 ' LCD Data Bit Sayisi
DEFINE LCD_LINES 2 ' LCD Satir Sayisi
SONUC1 VAR WORD
SONUC2 VAR WORD
X VAR WORD ' 1mS
EK VAR WORD
PIE1.0=1 ' 1 = Enables the TMR1 overflow interrupt
TRISB.0=1
T1CON=%00000001 ' bit 7-6 Unimplemented - bit 5-4=00 1:1 Prescale value - bit 0= 1=Disables Timer1
OPTION_REG.7=1 ' 1 = PORTB pull-ups are disabled
OPTION_REG.6=1 ' 1 = Interrupt on rising edge of RB0/INT pin
INTCON.4=1 ' 1 = Enables the RB0/INT external interrupt
INTCON.6=1 ' 1 = Enables all unmasked peripheral interrupts
INTCON.7=1 ' 1 = Enables all unmasked interrupts
CMCON=7 ' Turn comparators off and enable pins for I/O functions
ON INTERRUPT GOTO KESME ' Kesme Durumunda Gidecegi Alt Yordam
x=0
Basla:
@NOP
goto basla
DISABLE
KESME:
IF PIR1.0 THEN
IF X<1000 THEN X=X+1
PIR1.0=0
endif
IF INTCON.1 THEN
SONUC2=TMR1H*256+TMR1L
SONUC2=SONUC2/1000
SONUC1=X**65535
X=DIV32 1000
sonuc2=SONUC2+X
LCDOUT $FE,1,DEC SONUC2," mS Passed"
INTCON.1=0
X=0
endif
RESUME
ENABLE
Bookmarks