Using System Tick

Download pre-release library modules and new examples to use with Astrobe for Cortex-M. Forum members can also upload their own source code examples.
Post Reply
bscholte
Posts: 19
Joined: Sat Jan 24, 2015 6:15 pm
Location: Austria
Contact:

Using System Tick

Post by bscholte » Thu Nov 28, 2019 7:32 pm

We are building an "RTOS" an a LPC-1769-ARM3 and are using the standard Timer module, using Timer3 for a 10mS pulse which basically clocks everything. Following the documentation, the System Tick should do exactly the same thing. So, we thought it would be easy to convert the Timer module into a SysTick Module which does essentially the same. Unfortunately, it seems to be quite different...

Has anyone used the system tick on this processor?

With great thanks......

cfbsoftware
Site Admin
Posts: 493
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: Using System Tick

Post by cfbsoftware » Fri Nov 29, 2019 6:41 am

I haven't used it myself. Does this article help?

http://www.exploreembedded.com/wiki/LPC ... Tick_Timer

If not send us a minimal example of your code with a test program to exercise it and we'll investigate here.

bscholte
Posts: 19
Joined: Sat Jan 24, 2015 6:15 pm
Location: Austria
Contact:

Re: Using System Tick

Post by bscholte » Fri Nov 29, 2019 7:53 am

The article has more information than the NXP LPC manual, so it does help. In the LPC manual, the information is partly in the main section, but critical details are in the ARM section. For example, the NVIC offset vector seems to be at $3C, which is below the $40 that is the lowest in the NXP NVIC table.

Anyway, I will make a few more attempts and post the resulting Module.

Selectech
Posts: 2
Joined: Sun Nov 02, 2014 1:19 am
Location: Kanata, ON, Canada

Re: Using System Tick

Post by Selectech » Sat Nov 30, 2019 3:15 pm

I've used Systick on LPC1347 and LPC1768 ( and some other non-NXP controllers ). It's used for my RTOS work,

With a 96 Mhz clock, this sets up Systick to give 1 mSec tick.
The trap handler is just like any other interrupt handler.

(* System Tick Timer Handler *)
PROCEDURE SysTickTrap[1];
BEGIN
INC(mSec);
Timer_Ticked := TRUE;
(* other work to be done by tick Int goes here *)
END SysTickTrap;

(* Init the System Tick Timer Handler, 1 mSec tick *)
PROCEDURE Init_Systick;
CONST
SysTickVector = 01000003CH; (* from Cortex-M3 documentation *)
VAR direction : SET;
BEGIN
SYSTEM.PUT(MCU.STCURR, 0 ); (* start from 0 *)
SYSTEM.GET(MCU.STCTRL, direction);
SYSTEM.PUT(MCU.STCTRL, direction - {1} + {0,2} );
SYSTEM.PUT(MCU.STRELOAD, 96000 ); (* using 96 Mhz clock *)

(* set Systick vector *)
Traps.Assign( SysTickVector , SysTickTrap );

SYSTEM.PUT(MCU.STCTRL, direction + {0,1,2} ); (* enable the interrupt *)
END Init_Systick;

bscholte
Posts: 19
Joined: Sat Jan 24, 2015 6:15 pm
Location: Austria
Contact:

Re: Using System Tick

Post by bscholte » Wed Dec 04, 2019 10:19 am

The posted Module works like a charm and frees up a Timer. Thanks!

The only difference for my LCP1769 at 120MHZ and a tick every 10mSec, is the RELOAD. The value given in the manual (120MHZ/100 - 1= 1199999) nicely produces the desired tick.

Cheers!

Post Reply