Timers and internal clock generator on Freescale MCU
Apparently, as the timer frequency is very high, to set it up we would require a large Prescaler Setting(i maxed out at 128). After having had a talk with my colleague, he says that i need to generate a Periodic "Tick" with the flash period for each LED set accordingly. So as to make sure that LED(ON or OFF) corresponds to the TICK rather than the Bus Clock Frequency.Ya, this works but i am still confused.


If you are able to use the datasheet to understand the various register functions, then why, setting the frequency of the timer as per requirement, doesnt work?
Moreover, isnt this "Tick" the same as the Delay funciton?? 


here is the code for the same(by the way this code was suggested to me at the freescale forum, but it might also help someone else; i take no credit for this code) :

// Assumed bus frequency: 8.0 MHz
// TPM prescale divisor:  4



// Global variables:
byte tic_cnt;             // Timer tick counter
byte ch_nbr;              // LED channel number



// LED mask values:
#define mLED0    0x01
#define mLED1    0x02
#define mLED2    0x04
#define mLED3    0x08
#define mLED4    0x10
#define mLED5    0x20
#define mLED6    0x40
#define mLED7    0x80



#define TIC_INCR 20000    // 10 ms tick period, with prescale 4


//***************************************************************

// LED blink polling function

void LED_poll( void)

{

   if (!tic_cnt)

  {        // Timeout occurred

      tic_cnt = 50;       // Start new 500ms timing interval


      ch_nbr++;

      if (ch_nbr == 8)  ch_nbr = 0;

      if (ch_nbr == 0)  PTFD = mLED0;  // Turn LED0 on, other LEDs off
      if (ch_nbr == 1)  PTFD = mLED1;  // Turn LED1 on, other LEDs off
      if (ch_nbr == 2)  PTFD = mLED2;  // Turn LED2 on, other LEDs off
      if (ch_nbr == 3)  PTFD = mLED3;  // Turn LED3 on, other LEDs off
      if (ch_nbr == 4)  PTFD = mLED4;  // Turn LED4 on, other LEDs off
      if (ch_nbr == 5)  PTFD = mLED5;  // Turn LED5 on, other LEDs off
      if (ch_nbr == 6)  PTFD = mLED6;  // Turn LED6 on, other LEDs off
      if (ch_nbr == 7)  PTFD = mLED7;  // Turn LED7 on, other LEDs off
   }
}

__interrupt VectorNumber_Vtpm1ch0 void ISR_TPM1_ch0( void)

{

   TPM1C0_CH0F = 0;       // Clear TPM channel flag

   TPM1C0V += TIC_INCR;   // Set next software compare

   if (tic_cnt)  tic_cnt--;
}