Hi,
I searched in the forum and found a peice of code by Bruce...
Everytime I press RA.4 it toggle RB0, I also put a variable that will display the value to the LCD, from the code I observed (please correct me if I wrong).Code:DEFINE LCD_DREG PORTBDEFINE LCD_DBIT 0 DEFINE LCD_EREG PORTB DEFINE LCD_EBIT 5 DEFINE LCD_RSREG PORTB DEFINE LCD_RSBIT 4 DEFINE LCD_BITS 4 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 2000 DEFINE LCD_DATAUS 50 PAUSE 100 TRISA.4 = 1 ' RA4/T0CKI = input to TMR0 counter TRISB.0 = 0 ' RB0 = output for LED CMCON = 7 ' All digital i var byte i=0 ' Assign prescaler to WDT for 1:1 prescale on TMR0 ' TMR0 clock will be from your external input on RA4/T0CKI ' Increment on high-to-low transitions OPTION_REG = 111000 ' If you prefer, then increment on low-to-high transitions ' OPTION_REG = 101000 Lcdout $fe, 128, "Counter: ", #i pause 100 Main: TMR0 = 0 ' Clear TMR0 count before start Loop1: WHILE TMR0 = 0 ' Wait for high-to-low transition WEND ' on RA4/T0CKI PORTB.0 = 1 ' LED on to indicate transition seen i=i+1 ' Increment Lcdout $fe, 128, "Counter: ", #i PAUSE 200 PORTB.0 = 0 ' LED off GOTO Main ' Start over END
a. Timer0 is selected
b. The signal entry is RA.4
c. It increments on low-to-high transitions
d. Pre scale value is 1:2 (000 of Bits 2,1)
d. The configuration setting used OPTION_REG = 111000
So if connect the multi coin acceptor to the RA.4 this should count the number of pulse?
thanks in advance,
tacbanon




Bookmarks