Skip to main content
Visitor II
May 23, 2007
Question

Timer 1 ms with STR75 and Raisonance print

  • May 23, 2007
  • 2 replies
  • 663 views
Posted on May 23, 2007 at 10:45

Timer 1 ms with STR75 and Raisonance print

    This topic has been closed for replies.

    2 replies

    xavioooAuthor
    Visitor II
    May 22, 2007
    Posted on May 22, 2007 at 15:21

    Hello everybody,

    I'm trying to create a 1ms timer with a STR750 microcontroller.

    void TB_Configuration(void)

    {

    /* TB configuration in Timing mode */

    TB_InitStructure.TB_Mode = TB_Mode_Timing;

    TB_InitStructure.TB_ClockSource = TB_ClockSource_CKTIM;

    TB_InitStructure.TB_Prescaler = 29; /* TB clock = 60MHz / (29 +1) = 2 MHz*/

    TB_InitStructure.TB_CounterMode = TB_CounterMode_Up;

    TB_InitStructure.TB_AutoReload = 19; /* update each: 2 MHz/(19+1)= 100 KHZ ---> 10 us */

    TB_Init(&TB_InitStructure);

    TB_ITConfig(TB_IT_Update, ENABLE);/* Enable TB update interrupt */

    TB_Cmd(ENABLE); /* Enable TB counter */

    }

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

    .... //EIC ENABLE

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

    void TB_IRQHandler(void)

    {

    INC_10us++;

    TB_ClearITPendingBit(TB_IT_Update);

    }

    Works

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

    void WaitClock(u16 time)

    {

    while (INC_10us < time)

    {

    Here is the problem

    print('' INC_10us: %d \r'',INC_10us);[/B] // Raisonance print

    }

    INC_10us = 0; //Reset counter

    }

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

    main

    {

    ... // INIT

    while(1)

    {

    WaitClock(100); // Wait 10 * 100us = 1ms

    }

    }

    Problem

    In the function WaitClock, when I don't use the function print, i'm stuck in the while of the function.

    When I use the function print, it works, but the timer is a 20 ms timer instead of a 1 ms timer.

    Of course, I'd prefer not to use the function print.

    Is there an obvious mistake ?

    Did anyone have the same problem ?

    Thank you again.

    -Xavier

    xavioooAuthor
    Visitor II
    May 23, 2007
    Posted on May 23, 2007 at 10:45

    Well,

    First problem solved : print function takes too long :-? .

    I have a 1 ms timer:).

    Second problem :

    This works... but it's ugly... It's the best I can do for now?

    -------------------------------------------------

    void WaitClock(u16 time)

    {

    while (INC_10us < time)

    {

    Here is the problem

    GPIO_WriteBit(GPIO0, GPIO_Pin_4, 0);

    }

    INC_10us = 0; //Reset counter

    }

    -------------------------------------------------

    Why this doesn't work ?:

    void WaitClock(u16 time)

    {

    while (INC_10us < time);

    INC_10us = 0; //Reset counter

    }