0
\$\begingroup\$

I'm trying to use SysTick_Handler in a project which uses the mbed libraries and RTOS, however on compilation, the following error is returned: Error: Symbol SysTick_Handler multiply defined (by ../../build/mbed-os/rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_M3/irq_cm3.LPC1768.o and ../../build/main.LPC1768.o).

This leads me to believe that SysTick_Handler is used somewhere in the mbed library. Does this mean I cannot use it, and I have to resort to using the LPC1768s Timers?

The other definition appears to be in irq_cm3.0

Boiled down version of code:

#include "mbed.h"
#include "EthernetInterface.h"


extern "C" void SysTick_Handler()
{


}

// Socket demo
int main()
{
SysTick_Config(SystemCoreClock / 1000); 

}
\$\endgroup\$
  • 1
    \$\begingroup\$ The compiler should tell you exactly where the two definitions occur...in which files. Look at the entire error message. You also need to show us your code. \$\endgroup\$ – Elliot Alderson Apr 4 at 18:54
  • \$\begingroup\$ It seems likely to me that the mbed libraries will provide you with a callback/hook to allow you to link your own handler to the existing one. \$\endgroup\$ – brhans Apr 4 at 18:58
  • \$\begingroup\$ @ElliotAlderson, please see updated question. \$\endgroup\$ – 19172281 Apr 4 at 19:02
  • \$\begingroup\$ Looks like you need to either put your code in the existing function, call your code from the existing function, or remove that and substitute your own. Any of these may break compatibility with future MBED versions so you'll need to do something like use a version control system to keep careful track of what changes you make on top of the upstream. That said, it's not entirely convincing that you have found the code in use; one would expect a counter to be incremented and likely some pumping of the RTOS scheduler, unless it is operating off a different timer. \$\endgroup\$ – Chris Stratton Apr 4 at 19:08
  • \$\begingroup\$ For the record, it is the linker which would notice multiple definition, not the compiler. \$\endgroup\$ – Chris Stratton Apr 4 at 19:09
0
\$\begingroup\$

As said in the comments, the SysTick timer is indeed in use by the RTOS and you should not muck with this. Use the Ticker class if you need to tick regularly, it will drive the underlying high-precision timer on the platform (and is portable code). An additional benefit is that multiple Tickers can be created and they'll all use the same hardware timer.

void tick() {
    // do things, note that this runs in an ISR
}

Ticker t;
t.attach_us(&tick, 1000 /* 1ms. */);
\$\endgroup\$
  • \$\begingroup\$ Can I use Timer0, if I need lower level control? \$\endgroup\$ – 19172281 Apr 5 at 12:23
  • \$\begingroup\$ Sure, but would you actually need it? You can set which timer source is used for the Ticker yourself, and then Mbed OS will do all the bookkeeping. \$\endgroup\$ – Jan Jongboom Apr 7 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.