Hello all and good years
I will want a counter per minute with:
-count pulses in RB0
-setting tmr0 (prescaler 256) + loop but it can't works
what is wrong please
'************************************************* ***************
'* Name : Compte tour.BAS
'* Author : [set under view...options]
'* Notice : Copyright (c) 2005 [set under view...options]
'* : All Rights Reserved
'* Date : 31/12/2005
'* Version : 1.0
'* Notes :
'* :
'************************************************* ***************
Adcon1=7
Define osc 20
TRISB=%00000001 ' setting port B
TRISA=%00000000 ' setting port A
OPTION_REG=%01001111 ' inerruption RB0/INT
' Incrrase tmr0
' prescaller 256
INTCON = %10010000 ' setting INTCON
'-------------------------------------------------------------------------------
'setting LCD
DEFINE LCD_DREG PORTB ' LCD o/p on port B
DEFINE LCD_DBIT 4 ' LCD on lower 4 bits of port B
DEFINE LCD_RSREG PORTB ' LCD reset on port B
DEFINE LCD_RSBIT 3 ' LCD reset portB.3
DEFINE LCD_EREG PORTB ' LCD enable on port B
DEFINE LCD_EBIT 2 ' LCD output on PortB.2
DEFINE LCD_BITS 4 ' LCD o/p is 4 bit data
DEFINE LCD_LINES 2 ' Number of lines on LCD = 2
'-------------------------------------------------------------------------------
Compte_pulse var word
Compte_timer0 var word
Tours_minute var word
'-------------------------------------------------------------------------------
On interrupt goto Isr
'-------------------------------------------------------------------------------
Main:
If intcon.2=1 then
Compte_timer0=Compte_timer0+1
intcon.2=0
endif
if Compte_timer0=58500 then
Tours_minute=Compte_pulse*20
Lcdout$fe,1
Lcdout,#Tours_minute," Tours/mn"
'-------------------------------------------------------------------------------
Compte_timer0=0
Compte_pulse=0
endif
Goto Main
disable
'-------------------------------------------------------------------------------
Isr:
Compte_pulse=Compte_pulse+1
INTCON.1 = 0 'flag d'interruption à 0
resume
enable
Bookmarks