Open inafucoAugusto opened 1 year ago
However if we change the file to a .CPP (executing all steps to converting the project from .C to .CPP) we are not able to use the IRQ.
Bruh.
If you use a .cpp
file you will get name mangling, so the symbol emitted by a function like
void IRQHandler() {
}
it will emit a mangled symbol (due to C++ supporting overloaded functions that must be disambiguated somehow).
So you need to add an extern "C"
declaration to have C linkage (disabling of name manling)
extern "C" void IRQHandler() {
}
or in your above case where you have the function declaration above the implementation, that line just needs to be prefixed with extern "C"
(line 86).
See
We tried to reproduce the IRQ D0 example from the project shown bellow (path: openwch/ch32v003/EVT/EXAM/EXTI/EXTI0).
If we use the main file as a .C file the issue is not reproducible. However if we change the file to a .CPP (executing all steps to converting the project from .C to .CPP) we are not able to use the IRQ.
Using the debug tool we reached the following result:
Right after pressing the D0 button, we expect the IRQ defined in the .CPP file (this IRQ is the same from exaple EXTI0), but it got stuck at the "EXTI7_0_IRQHandler: 1: j 1b".