COUNT is not counting again


Results 1 to 34 of 34

Threaded View

  1. #21
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    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.

Similar Threads

  1. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd March 2009, 23:14
  2. Remain counting while sending out a pulse
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th January 2007, 15:51
  3. hardware counting while software runs
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd October 2006, 03:26
  4. continious counting process (capture)
    By asynch in forum General
    Replies: 1
    Last Post: - 17th February 2006, 07:42
  5. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 19:04

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts