Go Down

Topic: sysTickHook (Read 704 times) previous topic - next topic


I can't seem to get sysTickHook() to work.
The code below never prints "Tick". Google suggests I need to wrap extern "C"{} around the function, but that gives me a compile error stating that the function is already defined.
Code: [Select]
int hooktimer = 1000;

void setup() {

void loop() {

int sysTickHook(void)
  if (--hooktimer == 0) {
    hooktimer = 1000;
  return 0;

It appears I may not be the only one with this problem:


The original SysTick_Handler from cortex_handlers.c is overdefined in Arduino15\packages\arduino\hardware\sam\1.6.7\cores\arduino\main.cpp and it does not take care about sysTickHook


It is already defined before, but a weak definition "__attribute__((weak))", you can redefine it with your own code in C.
".ino" extensions are treated like C++ where you can't redefine those functions. The approach for that is by using C language inside as follows

Code: [Select]

#ifdef __cplusplus
extern "C" {

// C code

int sysTickHook() {

           // your code


// more C code

#ifdef __cplusplus

Go Up