cancel
Showing results for 
Search instead for 
Did you mean: 

system tick timer - my program freezes

mehmet.karakaya
Associate III
Posted on September 27, 2010 at 09:35

system tick timer - my program freezes

14 REPLIES 14
kashif
Associate II
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.

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

for 100ms

 SysTick_SetReload(900000);

mehmet.karakaya
Associate III
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
Posted on May 17, 2011 at 14:09

nobody knows anything about system_tick ?

trevor23
Associate III
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.

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

can anybody comment why my first message example doesnot work ?

mehmet.karakaya
Associate III
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 )

trevor23
Associate III
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

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 Up vote any posts that you find helpful, it shows what's working..