cancel
Showing results for 
Search instead for 
Did you mean: 

Code for enabling Timer4 Interrupt

JJAYAR
Associate II

Using NUCLEO F756ZG & STM Cube IDE

I am trying to setup & enable interrupt for TIM4

The compiler is not happy with these 4 lines of code

 

TIM4->ARR=5000;
NVIC_SetVector(TIM4_IRQn, (uint32_t)&TIM4_IRQHandler);
NVIC_SetPriority(TIM4_IRQn,0);
NVIC_EnableIRQ(TIM4_IRQn);
TIM4->DIER|=TIM_DIER_UIE;
TIM4->CR1 |= 0x1;

 

Error#1

for line

NVIC_SetVector(TIM4_IRQn, (uint32_t)&TIM4_IRQHandler);
//NOTE: TIM4_IRQHandler() is declared

it gives this error

../Core/Src/main.c: In function 'main':
../Core/Src/main.c:100:40: error: 'TIM4_IRQHandler' undeclared (first use in this function); did you mean 'RNG_IRQHandler'?
100 | NVIC_SetVector(TIM4_IRQn, (uint32_t)&TIM4_IRQHandler);
| ^~~~~~~~~~~~~~~
| RNG_IRQHandler

Error#2

For lines

NVIC_EnableIRQ(TIM4_IRQn);
TIM4->DIER|=TIM_DIER_UIE;

the compiler gives..

Error in final launch sequence:

Setup exceptions
Setup exceptions

I was wondering if any one has encounterd these errors

The Timer4 is he only peripheral I have in my program

Any comments/feedback appreciated

Thanx

Jay

2 REPLIES 2
SofLit
ST Employee

Hello,

TIM4_IRQHandler() is generally declared in xxx_it.c file. 

Could you please attach your project package as we can have a close up look?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
JJAYAR
Associate II

Hi SofLit,

I retried running the project & the problem seems to have gone away

Not sure what I did but I am not able to reproduce the issue

I think I will close this problem request - may be bring it up If I face the problem again

Thanx for your help

Jay