
Originally Posted by
jellis00
This time with the code:
Code:
@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
K CON 15 ' Calibration factor for flow meter = # pulses per gal
' Setup Timer0 as an 8-bit counter with the clock input on RA2.
' 1:1 TMR0 prescaler
' TMR0 counts on high-to-low transitions
OPTION_REG = %00111000
' A/D & Comparators disabled
ANSEL=0 ' all digital
ANSELH=0 ' analog module disabled
CM1CON0=0
CM2CON0=0
' Port setup
PORTC = 0 ' LEDs off, PULSOUT RC3 provides a high-going pulse
PORTA = 0
TRISC = %11110000 ' lower 4 pins outputs
TRISA = %11111111 ' RA2 = 2TMR0 clock input for simulated meter pulse inputs
TMR0 = 0 ' clear TMR0 count
WPUA.2 = 1 ' enable weak pull-up on RA2
Main:
IF TMR0 < K THEN
WRITE 7, TMR0 ' write count during testing
' Keep the valve open...do nothing..let water flow
HIGH PORTC.0 ' Blink Light LED while water is flowing
Pause 500
LOW PORTC.0
PAUSE 500
ELSE
WRITE 9, TMR0 ' write count during testing before clearing
TMR0 = 0 ' clear TMR0 count
PULSOUT PORTC.3,1000 ' Generate required 10 msec pulse to RC3
ENDIF
GOTO Main
END
try masking the interrupt just before write and reenable right after.
Code:
eecon1 = 6 ' enables eeprom write
intcon.7 = 1
write address, data
intcon.7 =0
Last edited by Archangel; - 8th May 2009 at 09:35.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks