RIT timer intervall

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RIT timer intervall

457 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by inspire on Thu Jun 07 04:25:45 MST 2012
hi,

I've got some problems with the RIT timer interval.

The interrupts are generated not with the desired frequency.
E.g. interrupt interval of 10 seconds is required.

    uint32_t TimerInterval = 10000; // 10 seconds
    
    /* By default, the PCLKSELx value is zero, thus, the PCLK for
     all the peripherals is 1/4 of the SystemFrequency. */
    /* Bit 26~27 is for RIT_TIMER */
    pclkdiv = (LPC_SC->PCLKSEL1 >> 26) & 0x03;
    switch (pclkdiv) {
    case 0x00:
    default:
        pclk = SystemCoreClock / 4;
        break;
    case 0x01:
        pclk = SystemCoreClock;
        break;
    case 0x02:
        pclk = SystemCoreClock / 2;
        break;
    case 0x03:
        pclk = SystemCoreClock / 8;
        break;
    }

    LPC_RIT->RICOMPVAL = (pclk / TimerInterval) - 1;
But the interrupts don't follow the 10 seconds, they occur too fast.

You've got a hint for me?

Thanks in advance.
0 Kudos
Reply
7 Replies

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by inspire on Fri Jun 08 05:21:15 MST 2012
Oh sorry, what was I thinking?

uint32_t TimerInterval = 100;

LPC_RIT->RICOMPVAL = pclk/TimerInterval;


means there will be interrupts at 100 Hz.
0 Kudos
Reply

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 07 12:29:06 MST 2012

Quote: inspire
:confused:

So with these values there will be interrupts every 100 seconds?


 
:confused:

Did you read #3 of this thread?
0 Kudos
Reply

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by inspire on Thu Jun 07 12:07:01 MST 2012
:confused:

So with these values there will be interrupts every 100 seconds?
0 Kudos
Reply

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 07 12:02:36 MST 2012

Quote: inspire
Ah i see. So if I use

uint32_t TimerInterval = 100;

LPC_RIT->RICOMPVAL = pclk/TimerInterval;
there will be interrupts with 10 Hz?

Sorry, I cannot test it until Monday.

Martin



:confused:

Perhaps you can find Monday someone who can explain you how many Hz 1/100s are :rolleyes:
0 Kudos
Reply

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by inspire on Thu Jun 07 11:52:27 MST 2012
Ah i see. So if I use

uint32_t TimerInterval = 100;

LPC_RIT->RICOMPVAL = pclk/TimerInterval;


there will be interrupts with 10 Hz?

Sorry, I cannot test it until Monday.

Martin
0 Kudos
Reply

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 07 04:37:30 MST 2012
Hint: RIT is a dumb counter. It's counting to LPC_RIT->RICOMPVAL, interrupts and starts with 0 again :eek:

So what did you write to this counter? CLK/4/10000 :)

And this timer is running with CLK/4 :)

So it needs about (CLK/4/10000)/(CLK/4) seconds = 1/10000 s :mad:
0 Kudos
Reply

418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Thu Jun 07 04:34:48 MST 2012

Quote: inspire
hi,

I've got some problems with the RIT timer interval.

The interrupts are generated not with the desired frequency.
E.g. interrupt interval of 10 seconds is required.

    uint32_t TimerInterval = 10000; // 10 seconds
    
    /* By default, the PCLKSELx value is zero, thus, the PCLK for
     all the peripherals is 1/4 of the SystemFrequency. */
    /* Bit 26~27 is for RIT_TIMER */
    pclkdiv = (LPC_SC->PCLKSEL1 >> 26) & 0x03;
    switch (pclkdiv) {
    case 0x00:
    default:
        pclk = SystemCoreClock / 4;
        break;
    case 0x01:
        pclk = SystemCoreClock;
        break;
    case 0x02:
        pclk = SystemCoreClock / 2;
        break;
    case 0x03:
        pclk = SystemCoreClock / 8;
        break;
    }

    LPC_RIT->RICOMPVAL = (pclk / TimerInterval) - 1;
But the interrupts don't follow the 10 seconds, they occur too fast.

You've got a hint for me?

Thanks in advance.



Hi...!!!

Have you measured the time interval and how often is it occurring.


Thanks & Regards.....:)
0 Kudos
Reply