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
Andrew Neil
Evangelist II
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''...?

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

I am sorry , I am very new to ARM ( ~ 1 month )

( but not new to embedded )

I have no JTAG thats why I have no tool to debug deep inside

if I code  '' SysTick_Config(SystemCoreClock); '' the program doesnot freeze

but the system tick return 1 ( which means it doesnot initialize )

If I code  '' SysTick_Config(SystemCoreClock/10 ); '' this time the program freezes - where can I put a trap ? if the program freezes - I need a working code to debug

it means something wrong with systick function - which is declared in core_cm3.h

I am sorry I bothered you with my questions

I have given up systick - I have written a simple TIMER6 code

so I get a 100 ms tick with TIMER6

thank you for your help
Andrew Neil
Evangelist II
Posted on May 17, 2011 at 14:09

''I have no JTAG''

Then

get

one

!!

 

It is absolute folly to deliberately handicap yourself like this!

Posted on May 17, 2011 at 14:09

ST provides source to the library, so you can examine it.

SysTick_Config() fails if the value passed is wrong/out-of-range.

If you have a serial port, use it to instrument the code, and evaluate what SystemCoreClock / 10 actually is.

Get a JTAG pod, or a board with one. The STM32 VL Discovery board is ~$10, and includes a ST-LINK JTAG. Trying to debug a CPU as complex as an ARM without access to JTAG is a recipe for frustration and delay. Why don't you have one?

When posting a question it is useful to post complete source (not redacted/abbreviated). Provide information on the tool chain, version, and model of STM32 being used. Its pretty much impossible to come up with answers if you don't have usable information and have to guess about symptoms/solutions.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kashif
Associate II
Posted on May 17, 2011 at 14:09

sorry for coming late... i didn't get any email or alert (how to use alert system of this forum?)

lets start from beginning...

clive1 is right... these functions are from older library and defined in these files

''stm32f10x_systick.c and stm32f10x_systick.h''

if you are using Ride7 IDE, in project settings goto ''Use Old Precompiled Library'' and mark it

''yes''

, then include stm32f10x_systick.h in your project and these functions will work.

new library use

SysTick_Config()

  function to initialize SysTick timer. 

it is defined in core_cm3.h file. include this file in your project.

here is this function

/* ###    SysTick function  ### */

#if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)

/* SysTick constants */

#define SYSTICK_ENABLE              0      /* Config-Bit to start or stop the SysTick Timer                         */

#define SYSTICK_TICKINT             1        /* Config-Bit to enable or disable the SysTick interrupt                 */

#define SYSTICK_CLKSOURCE           2    /* Clocksource has the offset 2 in SysTick Control and Status Register   */

#define SYSTICK_MAXCOUNT       ((1<<24) -1)    /* SysTick MaxCount                                                      */

/**

 * @brief  Initialize and start the SysTick counter and its interrupt.

 *

 * @param  uint32_t ticks is the number of ticks between two interrupts

 * @return  none

 *

 * Initialise the system tick timer and its interrupt and start the

 * system tick timer / counter in free running mode to generate 

 * periodical interrupts.

 */

static __INLINE uint32_t SysTick_Config(uint32_t ticks)

  if (ticks > SYSTICK_MAXCOUNT)  return (1);                                                /* Reload value impossible */

  SysTick->LOAD  =  (ticks & SYSTICK_MAXCOUNT) - 1;                                         /* set reload register */

  NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);                               /* set Priority for Cortex-M0 System Interrupts */

  SysTick->VAL   =  (0x00);                                                                 /* Load the SysTick Counter Value */

  SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<<SYSTICK_ENABLE) | (1<<SYSTICK_TICKINT);    /* Enable SysTick IRQ and SysTick Timer */

  return (0);                                                                               /* Function successful */

}

#endif

now as you can see 

SYSTICK_MAXCOUNT = 0xFFFFFF

so input to this function must be less than or equal to SYSTICK_MAXCOUNT.

this is where, probably you are making mistake. 

i hope this will work for you now!!!!!!

still want to ask something, you are welcome. there is an example code in std_periph_lib for SysTick Timer... see that too.

Regards.