Skip to main content
Associate II
Mar 7, 2024 6:23 AM UTC
Question

Code for enabling Timer4 Interrupt

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

This topic has been closed for replies.

2 replies

mƎALLEm
ST Technical Moderator
Mar 7, 2024 11:40 AM UTC

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 "Best answer" on the reply which solved your issue or answered your question.
JJAYARAuthor
Associate II
Mar 20, 2024 3:55 AM UTC

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