Timer interrupt handler on SAM3x8e – Arduino Due
-
I really do not know where to post this and I hope I can explain my question , so be gentle. I am using SAM3x8e hardware timer (TC3) as an interrupt. The “TC3_Handler” (callback?) global function name is “hardcoded” somewhere and fires as expected at desired intervals. I do some verification of this by outputting simple message to LCD. The LCD “class” is declared / instantiated as a global class to the entire application and works amicably. Simple “lcd.print(“OK”)” is executed just fine in the TC3 handler. I also do some hardware output – turn on / off LED – just for an additional indication the handler is being executed. Now I want to execute a method / function of ANOTHER globally defined / instantiated class, again in same TC3 handler. Adding cpal.Run(); did not compile – undefined “cpal”. I had to ADD extern CPAL cpal; so it would compile and execute cpal.Run(); My question is both LCD and CPAL classes are global, the LCD can be used OK, but the CPAL has to have the extern “reference” added into the TC3 handler. Why? Thanks for reading, appreciate any help. Cheers Vaclav
-
I really do not know where to post this and I hope I can explain my question , so be gentle. I am using SAM3x8e hardware timer (TC3) as an interrupt. The “TC3_Handler” (callback?) global function name is “hardcoded” somewhere and fires as expected at desired intervals. I do some verification of this by outputting simple message to LCD. The LCD “class” is declared / instantiated as a global class to the entire application and works amicably. Simple “lcd.print(“OK”)” is executed just fine in the TC3 handler. I also do some hardware output – turn on / off LED – just for an additional indication the handler is being executed. Now I want to execute a method / function of ANOTHER globally defined / instantiated class, again in same TC3 handler. Adding cpal.Run(); did not compile – undefined “cpal”. I had to ADD extern CPAL cpal; so it would compile and execute cpal.Run(); My question is both LCD and CPAL classes are global, the LCD can be used OK, but the CPAL has to have the extern “reference” added into the TC3 handler. Why? Thanks for reading, appreciate any help. Cheers Vaclav
-
Probably because
LCD
global object is declaredextern
in one of the headers included by your source file containing theTC3
handler. -
Thanks, makes perfect sense. I am not sure I'll spent time to actually look for such declaration, but I need to learn more about hardware interrupts so maybe I'll run into it sooner or later. Thanks again. Vaclav