Hi

I think that TIM2 clock is 60MHz (APB1 clcok is 30MHz).
You should add update event generation.


  static void timer2_setup ( void ) {

    /* Set timer start value. */
    TIM_CNT(TIM2) = 1;

    /* Set timer prescaler. 72MHz/1440 => 50000 counts per second. */
    TIM_PSC(TIM2) = 20000; // 120M/2000 = 60k/second

    /* End timer value. If this is reached an interrupt is generated. */
    TIM_ARR(TIM2) = 600;

+  /* Load prescaler value. */
+  TIM_EGR(TIM2) = TIM_EGR_UG;
+
+  /* Clear update interrupt. */
+  TIM_SR(TIM2) &= ~TIM_SR_UIF;
+
    /* Update interrupt enable. */
    TIM_DIER(TIM2) |= TIM_DIER_UIE;

    //timer_set_repetition_counter ( TIM2, 100 );

    /* Start timer. */
    TIM_CR1(TIM2) |= TIM_CR1_CEN;

    return;
  }


Regards,
Toshiaki Yoshida

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
libopencm3-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libopencm3-devel

Reply via email to