Timer problem on LPC 1343

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

Timer problem on LPC 1343

2,171 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kacso on Fri Aug 24 09:21:07 MST 2012
Hi!

I'm trying to initalize timer32 so that he makes an interrupt every second, but I don't know what should I put for TimerInterval.
I try with this: init_timer32(1, 72000000); what should be normal (at least I think so) because frequency is 72MHz but it is to fast (In 3-4 hours it generate 3 interrupts more than he should.
I read somewhere that it sholud be 71999999 but of course it's to fast too.
:confused:
0 Kudos
Reply
10 Replies

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kacso on Fri Sep 07 10:30:26 MST 2012
Probably that is the problem :).
Thanks all for help.
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TommyBurger on Fri Sep 07 08:39:45 MST 2012
Consider the accuracy of your reference clock, that is, your PC. PC's are generally inaccurate. Also consider the accuracy of the oscillator on you uC. Then one second in a couple of hours may seem reasonable.

Recently, I needed a good time reference to verify our products accuracy. The cheapest solution for me was a Garmin GPS unit with a 1 pulse per second output.
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kacso on Fri Sep 07 03:47:41 MST 2012
I try it but there is the same problem.
Thanks for trying to help :)
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Thu Sep 06 17:21:47 MST 2012
Use the SystemCoreClock variable:

/* 1 second interval */
timer32(1,SystemCoreClock / 1);



That works great for me (although I used / 1000 for a 1ms interval).
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kacso on Thu Sep 06 05:20:35 MST 2012
I try in new project with the same timer and write counts on oled (on base board) but timer is to fast again. In less than 2 hours he counts 1 second more than my computer clock.
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Sep 05 10:37:16 MST 2012

Quote: kacso
Any idea?



#1 Create a new project and add your timer ;)

#2 Test Debug and Release Version :confused:

#3 Post it :)
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kacso on Wed Sep 05 07:57:04 MST 2012
I assigned the highest priority to the timer but there is no change, timer is too fast again. I think that priority doesn't mean anything in this problem because timer could just be to slow if priority is to low, but it couldn't be to fast.
I thought that the problem is with clearing interrupt in interrupt handler, I was doing it on the end, now I clear it on the beginig of handler, but there is no change.

Any idea?
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Aug 26 05:49:14 MST 2012
CMSIS is supporting you with priority functions:

core_cm3.h:

    This function sets the priority for the specified interrupt. The interrupt 
    number can be positive to specify an external (device specific) 
    interrupt, or negative to specify an internal (core) interrupt.

    Note: The priority cannot be set for every core interrupt.

    \param [in]      IRQn  Number of the interrupt for set priority
    \param [in]  priority  Priority to set
 */
static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
  if(IRQn < 0) {
    SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M  System Interrupts */
  else {
    NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff);    }        /* set Priority for device specific Interrupts  */
}
Debugger should show you interrupt settings:

Peripherals View-> NVIC -> IRQ_3_0_PRIOIRITY (start at 0xE000 E400)

Unfortunately registers > 32 (= IRQ number) are not shown here :eek::mad::mad::eek:

So you have to open a new window to monitor this addresses (> 0xe00e41c) or you just read it back:

 NVIC_SetPriority(30,2);//TIMER_32_0_IRQn , 1);
 priority_value = NVIC_GetPriority(TIMER_32_0_IRQn);
  
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kacso on Sun Aug 26 03:33:44 MST 2012
Where can I see which is priority? I'm new with this.
0 Kudos
Reply

2,053 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Fri Aug 24 10:00:48 MST 2012
#1 Timer is counting digital, so Freq-1 is the correct value :eek:

#2 Which interrupt priority has your timer?
0 Kudos
Reply