Author Topic: Weird HW timer & Happy New Year  (Read 7516 times)

Offline syakovlev

  • Newbie
  • *
  • Posts: 20
    • View Profile
Weird HW timer & Happy New Year
« on: December 30, 2008, 08:08:13 PM »
Two HW timer are created and used in similar way in project based on uTasker SP5, but
10ms timer fired in 10ms
40ms timer fired in 30ms ???

#define T_RAMP_DLY            (CLOCK_LIMIT)(10.0*MILLISEC)        // do next step
#define T_MODE_DLY            (CLOCK_LIMIT)(40.0*MILLISEC)        // wait for integrator to be ballanced

uTaskerGlobalMonoTimer( (UTASK_TASK)(OWN_TASK | HARDWARE_TIMER), T_RAMP_DLY, E_RAMP );
uTaskerGlobalMonoTimer( (UTASK_TASK)(OWN_TASK | HARDWARE_TIMER), T_MODE_DLY, E_MODE );

What might be the reason? Thx.

Best wishes to all :)




Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Weird HW timer & Happy New Year
« Reply #1 on: December 31, 2008, 12:54:38 AM »
Hi

There were some improvements made to the Global HW Timer for the M5223x in SP6 and SP7 (both in GlobalTimer.c and M5223x.c). I suspect that this case will work correctly if you install these (or copy the relevant changes) - I checked with the simulator with SP8 and didn't see a reason why it should behave as you have seen.

However there are some cases (more complicated ones) that do seem to have some weaknesses and generally I recommend not using the GLOBAL HW TIMER if the following alternative solutions will do the job:

1. If the resolution is not very critical the GLOBAL SW TIMERS can still be used. By reducing TICK_RESOLUTION you can improve the SW timer resolution without greatly increasing the TICK loading (a value of 10 should be adequate in your case).

2. If you have a newer service pack installed (from SP7) you will also have PIT1 and DMA Timer support included.  Their use are shown in application.c when the defines TEST_PIT and TEST_DMA_TIMER are set. These allow very accurate (more accurate than GLOBAL HW TIMER due to individual interrupt call-backs) interrupts and, with 4 powerful DMA timers available, usually enough flexibility for application requirements without the need to multiplex timers.

3. If you don't really need multiple timers to operate in parallel you could start the second delay once the first fires - this may solve the issue that you have identified in SP5.

Regards and best wishes!!

Mark