Elapsed Timer Demo


Closed Thread
Results 1 to 40 of 112

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer Demo

    Here's one idea
    Code:
    Temp VAR BYTE
    
    If TimerRunning = 1 THEN
      If (PortA.2 = 1) OR (PortA.3 = 1) THEN
        Temp = PortA & %11111100
        PortA = Temp + DIM
      ENDIF
    ENDIF
    /Henrik.

  2. #2
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer Demo

    Henrik I see what you are doing but wouldnt this create an issue with the higher bits? For instance if I am understanding correctly, the higher bits are always at 1, which would indicate a high, which in the program would stop and reset the timer. If I were to make them 0 in the loop, they would never change to 1 when the switch was closed. Switches are on bits 4, 5, 6 and 7.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer Demo

    Hi,
    No, the high bits are not always 'at 1'.
    When doing a bitwise AND both "inputs" must be true for the "output" to be true. Thus Temp = PortA & %11111100 will do a 'copy' of PortA except the two LSB's will be forced to zero. All the other bits will be left as they are when PortA is read.

    Besides, it doesn't really matter what you write to the port/pins which are configured as inputs. If, for example, PortA.5 is an input and you write '1' to it it will still read the actual state that whatever is connected to it drives it to - which isn't neccesarily '1'. If you look at the schematic for the I/O pins you'll see that the output driver for the pin is disabled when TRIS is set (ie. pin is made an input). If it wasn't it would short out whatever drives the pin to either Vdd or Vss.

    /Henrik.

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Get elapsed time while TIMER samples pulses
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th March 2009, 16:27
  3. Elapsed Timer Demo in a PIC12F675
    By Leonardo in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 21st November 2008, 00:01
  4. Totally Baffled with Elapsed Timer
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th June 2008, 21:01
  5. Darrel Taylor Elapsed Timer
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th March 2008, 01:22

Members who have read this thread : 2

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