Timer / CCP Question


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2005
    Posts
    44

    Default Timer / CCP Question

    Hi,

    This is probably more a Microchip question rather than a PBP question, but seeing as im writing in PBP, I'll ask here 1st.

    Basically what im trying to find out is whether the TMR1L and TMR1H are reset when the timer is activated by T1CON.0 = 1 or if i need to reset them manually as i have in my code below?

    Code:
    startloop:
    CCP1CON = %00000110			' Enable the CCP1 capture, 4th rising edge
    T1CON.0 = 1 				' start the timer
    
    loop:
    IF (capture = 0) Then loop	' Wait here until captured 
    
    period.lowbyte = CCPR1L		' Store the captured value in
    period.highbyte = CCPR1H	' period variable
    T1CON.0 = 0 					' stop the timer
    CCP1CON = %00000000				' Disable the CCP1 capture
    TMR1L = 0					' Clear Timer1 low register
    TMR1H = 0					' Clear Timer1 high register

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Reset the Timer Manually

    Hi there,

    Stopping the Timer only disables the clock input.(As far as the block for 18F452 says). So you have to manually reset the timer registers. It is worth noting that the TMR1H registers are actually updated when you write something to the TMR1L. Thus the TMR1H should be written first. This ensures that all the 16bits get updated at the same time.

    Regrads

    Sougata

  3. #3
    Join Date
    Aug 2005
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    I forgot to mention the pic is a 16F628A, but should be the same in operation.

    So, theoretically, I should clear the timer values before starting the timer and enabling the CCP.

Similar Threads

  1. Simple Timer question
    By jimseng in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th September 2009, 23:12
  2. CCp module question.
    By robert0 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd January 2007, 00:28
  3. CCP question
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th December 2005, 17:08
  4. Timer Question 16f877
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th November 2005, 08:40
  5. Timer Question
    By aywho in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd October 2005, 21:54

Members who have read this thread : 1

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