Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRQ for cpp is not working #15

Open
inafucoAugusto opened this issue May 18, 2023 · 1 comment
Open

IRQ for cpp is not working #15

inafucoAugusto opened this issue May 18, 2023 · 1 comment

Comments

@inafucoAugusto
Copy link

We tried to reproduce the IRQ D0 example from the project shown bellow (path: openwch/ch32v003/EVT/EXAM/EXTI/EXTI0).

image

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:

image

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".

@maxgerhardt
Copy link

maxgerhardt commented May 22, 2023

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

kholia pushed a commit to kholia/ch32v003 that referenced this issue Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants