cancel
Showing results for 
Search instead for 
Did you mean: 

cannot use NVIC_SetVector

JustSomeGuy
Senior

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

11 REPLIES 11
Chris21
Senior

Apparently in main.c you have a reference to LPTIM1_IQRHandler; LPTIM1_IRQHandler is in the startup file, but LPTIM1_IQRHandler is not...

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);

Chris21
Senior

Why not implement the handler in main.c, over-riding the one in the startup file (which does nothing)?

Here are my main.c and stm32l0xx_it.c files 

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.

Pavel A.
Evangelist III

Trust the compiler, it won't lie. If it says undeclared, it is undeclared. So make it declared.

 

Absolutely useless answer.

Pavel A.
Evangelist III

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 */

 

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?