Timer3 Problems


Closed Thread
Results 1 to 2 of 2

Thread: Timer3 Problems

  1. #1
    Join Date
    Aug 2006
    Posts
    65

    Default Timer3 Problems

    I'm having problems making timer3 on my PIC18F2620 work. I want to use the external 20Mhz clock source to toggle the counter. Eventually. I want to generate an interrupt everytime the counter overflows, but I can't seem to even make it count. To test whether the counter is counting or not, I put in a simple test that turns a LED on until the counter overflows, then turns it off. The LED is always on, so I assume the counter isn't counting. Here is the code:

    '*************************************************
    TMR3ON VAR T3CON.BIT0
    TMR3CS VAR T3CON.BIT1
    T3SYNC VAR T3CON.BIT2
    T3CKPS0 VAR T3CON.BIT4
    T3CKPS1 VAR T3CON.BIT5
    T3CCP1 VAR T3CON.BIT3
    T3CCP2 VAR T3CON.BIT6
    RD16 VAR T3CON.BIT7
    TMR3IE VAR PIE2.BIT1
    TMR3IF VAR PIR2.BIT1
    GIEH var INTCON.bit7
    GIEL var INTCON.bit6

    TMR3ON = 1 ' ENABLE TIMER3
    TMR3CS = 0 ' TRIGGERED BY Fosc/4
    T3SYNC = 1 ' USE INTERNAL CLOCK
    T3CKPS0 = 1 ' PRESCALER = 8
    T3CKPS1 = 1 ' PRESCALER = 8
    T3CCP1 = 1
    T3CCP2 = 1
    RD16 = 0 ' 8 BIT READ/WRITE/MODE
    TMR3IE = 1 ' TIMER3 INTERRUPTS ENABLED
    GIEH = 1
    GIEL = 1

    LOOP:
    if tmr3if = 1 then
    LED = 1
    else
    LED = 0
    endif
    GOTO LOOP
    '************************************************* ***
    Can someone suggest what I'm doing wrong, or not doing at all???

    Joe

  2. #2
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    I got this working gang. Problem was that I had the interrupt enable bit set, but no interrupt handler.

    Joe

Similar Threads

  1. 2 PWM in 16F690 problems
    By ciendavila in forum mel PIC BASIC
    Replies: 9
    Last Post: - 27th April 2008, 09:03
  2. Input problems
    By ALFRED in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd July 2006, 21:02
  3. Problems with 16F876 on interrupts an WRITE / READ
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2005, 14:38
  4. Goto inside a gosub??? Problems...
    By leonel in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 13th October 2005, 12:17
  5. USART problems
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 47
    Last Post: - 6th March 2005, 21:45

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