Cortex-M0 SysTick registers

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all !

 

How to correctly enter the values of the timer registers of the SysTick into a variable ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure what you mean by that?

 

SysTick is a standard part of the Core - so should be covered by CMSIS: https://www.keil.com/pack/doc/CMSIS/Core/html/group__SysTick__gr.html ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Not sure what you mean by that?

 

SysTick is a standard part of the Core - so should be covered by CMSIS: https://www.keil.com/pack/doc/CMSIS/Core/html/group__SysTick__gr.html ?

 

I need something like this - uint8_t A = <register value>; - for ATSAMD10

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1
uint32_t A = SysTick->VAL;

?

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meolsen wrote:

uint32_t A = SysTick->VAL;

?

 

So I tried - but the contents of the variable in the "watch" (Microchip Studio 7 debugger) are indicated as "optimized out", but no value

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Then maybe elaborate a bit on what you're trying to do?

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kolobokov wrote:
the contents of the variable in the "watch" (Microchip Studio 7 debugger) are indicated as "optimized out"

That usually means that you never use the value of the variable.

 

So did you also get a a warning along the lines of "variable is assigned a value which is never used" ?

 

One way to try to force the compiler not to optimise-out such a variable is to make it volatile and/or global

 

See this tutorial on optimisation & the use of 'volatile': https://www.avrfreaks.net/forum/tutcoptimization-and-importance-volatile-gcc - although it focuses on AVR-GCC, the principles are general.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The best documentation for SysTick is on the ARM site https://developer.arm.com/docume...

 

Here is a simple delay implemented with the systick timer.

 

void DelayMs(uint32_t mS)
{
    int i;
    
    SysTick->LOAD = 4000 - 1;                                               /* reload with number of clocks per millisecond */
    SysTick->VAL = 0;                                                       /* clear current value register */
    SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk;   /* Enable the timer */
    for(i = 0; i < mS; i++)
    {
        while((SysTick->CTRL & 0x10000) == 0);     /* wait until the COUNTFLAG is set */
    }
    SysTick-> CTRL = 0;                            /* Stop the timer (Enable = 0) */
}

 

 

 

 

John Malaugh