counter/ internal clock


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    12

    Default counter/ internal clock

    i need to create a simple clock/counter that increments roughly every second. Accuracy is not very important so long as its approximatly 1sec. When the counter reaches a given value i'll use it to set a flag which i plan to use to drive another process.

    i'm using pic16F876a

    can anyone help, i'm still learning picbasic


    many thanks

    jim

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    DT

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    > Accuracy is not very important so long as its approximatly 1sec.

    Darrel - You forgot to list the obvious...

    PAUSE 1000

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default



    So true.

    _
    DT

  5. #5
    Join Date
    Apr 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    thanks for the replies

    i cant use pause as i have other processes that need to be run..

  6. #6
    Join Date
    Apr 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    can anyone help with the following code as its not working

    i'm trying to set the output to 100 if the timer is less than 5000 and 001 if its above....


    Code:
    device = 16F876a  	   			  	  	   'PIC device
    CMCON = 7 								   'disable comparators
    TRISB = %11111111 						   'Portb as inputs
    TRISA = %00000000 						   'Porta as outputs
    porta = %00000000 						   'Set all outputs low
    
    T1CON.0=0 'stop the timer
    TMR1H = 0 'Set the high part of the timer value to 0
    TMR1L = 0 'Set the low part of the timer value to 0
    T1CON.0=1 'start the timer
    
    MyCount VAR WORD
    
    Start:
    
    MyCount.HighByte = TMR0H	'Get high byte of counter
    MyCount.LowByte = TMR0L		'Get low byte of counter
     
    IF MyCount > 5000 THEN 'if the timer value > than your number
    
    porta = %00000001
    
    gosub timer_reset
    
    else
    
    porta = %00000100
    
    endif 
       
    Goto Start
    
    
    
    timer_reset:
    
    T1CON.0=0 'stop the timer
    TMR1H = 0 'Set the high part of the timer value to 0
    TMR1L = 0 'Set the low part of the timer value to 0
    T1CON.0=1 'start the timer
    
    return

Similar Threads

  1. external clock / internal clock
    By grounded in forum General
    Replies: 4
    Last Post: - 31st May 2008, 17:44
  2. Setting up internal clock correctly?
    By JohnM in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th March 2008, 20:29
  3. Replies: 14
    Last Post: - 26th September 2007, 05:41
  4. 16F688 Internal clock and MCLR
    By manxman in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th August 2007, 18:38
  5. 16F628 Internal clock
    By srob in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th February 2007, 18:46

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