2024-11-05 12:02 PM - edited 2024-11-05 12:17 PM
I am trying to write interrupts bare-metal style. When I try to set the interrupt vector for LPTIM1 (using B-L071Z-LRWAN1) using this method,
NVIC_SetVector(LPTIM1_IRQn, (uint32_t)&LPTIM1_IRQHandler);
the compiler gives me this error:
../Core/Src/main.c:87:48: error: 'LPTIM1_IRQHandler' undeclared (first use in this function); did you mean 'TIM6_IRQHandler'?
87 | NVIC_SetVector(LPTIM1_IRQn, (uint32_t)&LPTIM1_IRQHandler);
Which I find bizarre, since I am not using timer 6, and LPTIM1_IQRHandler is listed in startup_stm32l072czyx.s. I tried declaring LPTIM1_IRQHandler as an extern, but with no success. Attached is the startup file.
How do I fix this?
Solved! Go to Solution.
2024-11-05 01:08 PM
Where is main.c getting its prototype for the LPTIM1_IRQHandler() ?
The body is in the it.c file, do you have a prototype for it in main.h ?
This is the compiler complaining, not that the Linker can't find the body, weak or otherwise.
2024-11-05 12:10 PM
Apparently in main.c you have a reference to LPTIM1_IQRHandler; LPTIM1_IRQHandler is in the startup file, but LPTIM1_IQRHandler is not...
2024-11-05 12:16 PM
Yeah that was a typo which I corrected, but the result is still the same. Now it is
../Core/Src/main.c:87:48: error: 'LPTIM1_IRQHandler' undeclared (first use in this function); did you mean 'TIM6_IRQHandler'?
87 | NVIC_SetVector(LPTIM1_IRQn, (uint32_t)&LPTIM1_IRQHandler);
2024-11-05 12:27 PM
Why not implement the handler in main.c, over-riding the one in the startup file (which does nothing)?
2024-11-05 12:28 PM
2024-11-05 12:33 PM - edited 2024-11-05 12:36 PM
I am going by examples and courses, and this is the method that was presented in every one. Right now I would like to find out why using NVIC_SetVector() this way does not work for me, when the exact same implementation works for everyone else.
2024-11-05 12:36 PM
Trust the compiler, it won't lie. If it says undeclared, it is undeclared. So make it declared.
2024-11-05 12:39 PM
Absolutely useless answer.
2024-11-05 12:45 PM
> I am going by examples and courses
This is not enough unfortunately. If basic knowledge of C language is lacking, the examples cannot be understood.
/* But soon we'll have medical doctors practicing like that */
2024-11-05 12:56 PM - edited 2024-11-05 12:57 PM
I know what declaration is, you arrogant nobody. I am simply stating that your answer is useless because you just repeated what the compiler told me, but in a more snarky tone. And now you have taken to belittling me because you assume I don't know what a declaration is when I told you your answer is useless. Take a look at this attached file. Now compare it to the startup file I posted. Notice how TIM6_IRQHandler is defined as TIM6_DAC_IRQHandler from the startup file? So both TIM6_IRQHandler and TIM6_DAC_IRQHandler works as the last parameter of NVIC_SetVector(). So since LPTIM1_IRQHandler is also in the startup file, it should work the same. Except it doesn't. Heck just for good measure, I added
#define LPTIM1_IRQHandler1 LPTIM1_IRQHandler
in the bottom section of
/* Aliases for __IRQHandler */
and put that as the last parameter in NVIC_SetVector() with the same results. If you are such a pro at this, certainly you should able to answer exactly why neither of these are working, right? Or are you just going to cover up your own lack of knowledge with more belittling that is extremely telling of your insecurity?