TMR1 on PIC18F4550 does not increment

Discussion in 'Embedded Systems and Microcontrollers' started by stasse, Sep 6, 2010.

  1. stasse

    Thread Starter New Member

    Sep 6, 2010
    2
    0
    Hey all,
    i'm trying to set up timer 1 on a pic18f4550 in compare mode with the CCPregisters.

    When i simulate i see TMR1L go to 0xFF and then to 0x00 but the upper byte of TMR1 does not increment? I do not know what i'm doing wrong.

    I use the pic18f4550, mplab ide environment, c18 compiler en a ICD3 debugger

    Here is my setupcode:

    Code ( (Unknown Language)):
    1. void setupTimer()
    2. {
    3.     const tLong constValueForCCPR1 = ((configTICK_TIME   * (OSC_FREQ / OSC_PER_INST)) / 1000 ); //1000 is om msec van tick_time aan te passen
    4.     tLong valueForCCPR1;
    5.  
    6.     //timecount clearen
    7.     TMR1H = (tByte) 0x00;
    8.     TMR1L = (tByte) 0x00;
    9.  
    10.     //waarde in CCPR1 register steken
    11.     valueForCCPR1 = constValueForCCPR1;
    12.     CCPR1L = ( tByte ) ( valueForCCPR1 & ( tLong ) 0xff );
    13.     valueForCCPR1 >>= (tLong) 8;
    14.     CCPR1H = ( tByte ) ( valueForCCPR1 & ( tLong ) 0xff ); 
    15.  
    16.     //Compare mode
    17.     CCP1CONbits.CCP1M0 = SET_BIT;
    18.     CCP1CONbits.CCP1M1 = SET_BIT;
    19.     CCP1CONbits.CCP1M2 = CLEAR_BIT;
    20.     CCP1CONbits.CCP1M3 = SET_BIT;
    21.  
    22.     //alle instellingen qua timer1 en interrupts voor timer1
    23.     PIE1bits.CCP1IE = SET_BIT;      // CCP1 Interrupt Enable
    24.     //IPR1bits.TMR1IP = SET_BIT;        // CCP1 Interrupt Priority High
    25.  
    26.     T1CONbits.TMR1CS = CLEAR_BIT;       // Timer 1 Clock Source Bit -- zero equals internal clock
    27.     T1CONbits.T1CKPS1 = CLEAR_BIT;      // Prescale value
    28.     T1CONbits.T1CKPS0 = CLEAR_BIT;      // Prescale value
    29.     T1CONbits.RD16 = SET_BIT;           // Enable 16bit mode
    30.  
    31.     T3CONbits.T3CCP2 = CLEAR_BIT;       //Timer3 and Timer1 to CCPx Enable bits
    32.     T3CONbits.T3CCP1 = SET_BIT;         //Timer3 and Timer1 to CCPx Enable bits
    33.  
    34.     T1CONbits.TMR1ON = SET_BIT;         // Timer 1 On Bit
    35.     //freeRTOS gebruikt     INTCONbits.GIEL  nog, ma ik denk dak die ni moet gebruiken?
    36.  
    37.     //INTCONbits.INT0IE = CLEAR_BIT; //deze regel moet eerder bij startscheduler
    38.     INTCONbits.GIEL = SET_BIT;
    39.  
    40.     //RCONbits.IPEN = 0;
    41.     INTCONbits.GIEH = SET_BIT;
    42. }
    does anyone see what i'm doing wrong?
     
  2. stasse

    Thread Starter New Member

    Sep 6, 2010
    2
    0
    no ideas? Do you need more information?
     
Loading...