-
Notifications
You must be signed in to change notification settings - Fork 136
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
ADC Interrupts Vector is wrong on STM32F103 #248
Comments
Then the interrupt vector needs to be searched for like for UART: |
As per <vector position="12" name="ADC1"/> as per <vector position="18" name="ADC1_2"/> |
I get it. Will make PR pronto |
I really don’t like ST’s inconsistencies about peripheral instances across their devices, it’s super annoying. |
I recommend doing an |
Uff, this is going to be annoying: Different vectors for different instances:
Different vector names for different devices:
|
And the stm32f0 and stm32f3 implementation do not even have the I feel like this
|
What do you think about a generic class in line of: class {{name}}Interrupt{
protected:
typedef void (*Handler) ();
public:
static inline void
attachInterruptHandler(Handler handler=modm::dummy){
{{name}}Interrupt::handler = handler;
}
public:
static Handler handler;
}
{{name}}Interrupt::Handler {{name}}Interrupt::handler = modm::dummy;
MODM_ISR(ISR_NAME){
{{name}}Interrupt::handler();
} |
Offtopic: what is that |
https://beyondgrep.com |
I've been thinking about an NVIC wrapper for some time now. However, you still have to use the right IRQ name, which is really annoying. I cannot change the IRQ names (they are defined like this in the Reference Manual), nor can I create aliases (like ADC1 = ADC1_2, ADC2 = ADC1_2) since then the user overwrites the settings in the NVIC: NVIC_EnableIRQ(ADC1);
NVIC_DisableIRQ(ADC2); // overwrites ADC1 etc… So even if we have this |
There are also more interesting problems here: For GPIO EXTI I should be able to attach an handler per pin, but how do I do this without dynamic memory or a massive static array? How is the timing of this solution going to be? Would any such API still work on AVRs or at least be backwards compatible? |
Offtopic:
I quite like this feature. We were able to find the described bug using UndefinedHandlers. |
I thought that you could generate one linker script section per shared interrupt that would contain all the function pointers to the individual interrupts declared by the user (maybe with some metadata, like a mask containing the pending flag(s?)). That would probably be the fastest and least space consuming solution, but it would include a lot of magic linkerscript stuff. (We already have this for the But adding linkerscript sections to the AVR is a complete nightmare, due to the weird Harvard-Architecture with the completely separate address spaces, requiring you to do these horrible address acrobatics with |
So, using the linkerscript, calls to |
Yes, but the I think this mechanism would be pretty flexible, but it does add some overhead when you just use one function (although you might be able to use inline assembly to speed things up) and you need to declare the original IRQ handler somewhere and still do the NVIC settings arbitration (especially not accidentally turning off a shared interrupt, that can quickly get ugly). Somewhat complicated still. |
I mean the STM32 UART already does this, but in a manual way, minus the linkerscript. Due to the lbuild instance submodules (ie.
but only on this one STM32G0 device:
Still not a very generic solution. |
So… I can't stop thinking about this, here are a couple of interesting but incomplete thoughts:
|
As an offtopic question: |
Similarly to how you can add the I know that CRECT (or any NVIC-based RTFM scheduler) has an issue with tasks using a shared interrupts, since they then have to use the same priority. That was very similiar to the discussion above which is why the solution to this would be some generated demultiplexor for both modm and CRECT. |
Also note that the Rust version of CRECT has significantly more features, these blog posts are a good overview over what is possible: https://blog.japaric.io/tags/rtfm/ |
Thanks! It is in the lines of what I thought. I'll see more into it later. |
This block from
modm/src/modm/platform/adc/stm32/adc_interrupts.cpp.in
is wrong on STM32F103.The real name of this handler is
The text was updated successfully, but these errors were encountered: