Timer1 issues


Closed Thread
Results 1 to 2 of 2

Thread: Timer1 issues

  1. #1
    Join Date
    Jun 2008
    Posts
    30

    Cool Timer1 issues

    I'm learning how to use the hardware timers, and it can't seem to get the TMR1 working, i am using a pic16f628 with two 4 mhz crystals 1 on pins ra6,ra7 and they other on pins rb6,rb7 which i don't know for sure if it is necessary or should just use they internal crystal ?

    This is the code i have so far


    LED VAR PORTB.0
    LED1 VAR PORTB.1
    ON INTERRUPT GOTO TIMER1INT

    LED = 0
    LED1 = 0

    TRISA = %00000000
    TRISB = %00000000


    INTCON.7 = 1 ' ENABLE THE GLOBAL INTERRUPT
    PIE1.0 = 1 ' ENABLE THEY TMR1 INTERRUPT
    T1CON.1 = 1 ' SETS THE MODE TO EXTERNAL CLOCK RB6,RB7
    T1CON.2 = 0 ' SYNCORNOSES BOTH CRYSTALS
    T1CON.3 = 1 ' ENABLES THEY OSCILATOR RB6,RB7 ON
    T1CON.4 = 1 ' SETS THE SECOND BIT OF THE PRESCALER
    T1CON.5 = 1 ' SETS THE FIRST BIT OF THE PRESCALER
    TMR1L = 220 ' SETS THE LOW BIT PRESCALER
    TMR1H = 11 ' SETS THE HIGH BIT PRESCALER
    T1CON.0 = 0 ' ACTIVES THE TIMER

    Start:


    GoTo Start

    TIMER1INT:

    IF LED = 1 THEN
    LED = 0
    LED1 = 1
    ELSE
    LED = 1
    LED1 = 0
    ENDIF


    RETURN

    end

    Could really use some help thanks.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Hi,


    A crystal oscillator circuit is built in between pins T1OSI
    (input) and T1OSO (amplifier output). It is enabled by
    setting control bit T1OSCEN (T1CON<3>). The oscillator
    is a low power oscillator rated up to 200 kHz. It will
    continue to run during SLEEP. It is primarily intended
    for a 32 kHz crystal. Table 7-1 shows the capacitor
    selection for the Timer1 oscillator.
    The Timer1 oscillator is identical to the LP oscillator.
    The user must provide a software time delay to ensure
    proper oscillator start-up.
    Does this Datasheet excerpt ring you a bell somewhere ???

    use the main 4 Mhz osc ... ( TMR1CS = 0 )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Software PWM using Timer1
    By muqasim in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2009, 11:49
  2. Help with TIMER1 + SLEEP
    By Yodoad in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd May 2009, 15:07
  3. Time Period of Timer1
    By arnol34 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th May 2007, 00:31
  4. Timer1 and Interupt wierdness
    By mind in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd August 2005, 01:24
  5. Use of Timer1 with 16F819
    By Barry Johnson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th January 2005, 16:25

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