Skip to main content
mehmet.karakaya
Associate III
September 27, 2010
Question

system tick timer - my program freezes

  • September 27, 2010
  • 14 replies
  • 2505 views
Posted on September 27, 2010 at 09:35

system tick timer - my program freezes

    This topic has been closed for replies.

    14 replies

    kashif
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    for 100ms

     SysTick_SetReload(900000);

    kashif
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    your function 

    SysTick_Config () is not working properly

    use this for sysTick initialization

    int main(void)

    {

      /* SysTick end of count event each 10ms with input clock equal to 9MHz (HCLK/8, default) */

      SysTick_SetReload(90000);

      /* Enable SysTick interrupt */

      SysTick_ITConfig(ENABLE);

      /* Enable the SysTick Counter */

      SysTick_CounterCmd(SysTick_Counter_Enable);

    }

    in stm32f10x_it.c

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

    void SysTick_Handler(void)

    {

    TIMERJOB=1;

    }

    regards.

    mehmet.karakaya
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    nobody knows anything about system_tick ?

    mehmet.karakaya
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    hello thank you

    which include file shall I include for the functions you mentioned ?

    mehmet.karakaya
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    can anybody comment why my first message example doesnot work ?

    trevor23
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    To find what header to include get your IDE (or windows) to search for the function name in you project ( filter = *.h). This is something we all do all the time. This function is in the ST library.

    trevor23
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    As kashif87 already said it must be your systick_config function that is wrong. But since you have not provided your function there is no way for us to help you. Please provide the source and I will try to help.

    Trevor

    mehmet.karakaya
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    the source code of systick_config is not written by me

    it is a function from ST library

    all I do is to call systick_config function to set the tick to 100 milisecond

    and making a variable ''1'' in the systick_handler ISR

    please look my first message

    ( kashif ' s code is giving error becouse his functions

    not available in the ST library )

    Andrew Neil
    Super User
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    ''can anybody comment why my first message example doesnot work ?''

    Can you comment on what debugging you've done to determine where, exactly, your code is ''hanging''...?

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 14:09

    They are functions from the V2.x library, the current one inlines Systick_Config()

    But for goodness sake, how hard is it to code a simple Systick example, and post the complete source? The problem is probably in code you aren't showing, because this works just fine on the VL discovery board with Keil.

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

    #include ''stm32F10x.h''

    #include ''STM32vldiscovery.h''

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

    volatile int TIMERJOB = 0; // needs to be volatile

    void SysTick_Handler(void)

    {

      TIMERJOB = 1;

    }

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

    int main(void)

    {

      int led;

      /* Initialise LEDs LD3&LD4, both off */

      STM32vldiscovery_LEDInit(LED3);

      STM32vldiscovery_LEDInit(LED4);

      STM32vldiscovery_LEDOff(LED3);

      STM32vldiscovery_LEDOff(LED4);

      /* Setup SysTick Timer for 100 msec interrupts  */

      if (SysTick_Config(SystemCoreClock / 10))

      {

        /* Capture error */

        while (1);

      }

      TIMERJOB = 0;

      led = 0;

      /* main while */

      while(1)

      {

        if (TIMERJOB == 1)

        {

          TIMERJOB = 0;

          led ^= 1;

          if (led)

            STM32vldiscovery_LEDOff(LED3);

          else

            STM32vldiscovery_LEDOn(LED3);

        }

      }

      /* does not exit - kind of important */

    }

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

    #ifdef  USE_FULL_ASSERT

    void assert_failed(uint8_t* file, uint32_t line)

    {

      /* User can add his own implementation to report the file name and line number,

         ex: printf(''Wrong parameters value: file %s on line %d\r\n'', file, line) */

      /* Infinite loop */

      while (1)

      {

      }

    }

    #endif

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

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..