Skip to main content
Visitor II
March 7, 2024
Question

Code for enabling Timer4 Interrupt

  • March 7, 2024
  • 2 replies
  • 994 views

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

    Technical Moderator
    March 7, 2024

    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?

    JJAYARAuthor
    Visitor II
    March 20, 2024

    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