cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO F411RE timer in order to generate an interrupt

Roman_E
Associate III

Learning on how to code 4x4 keypad with F411RE I came to need to learn 

timer in order to generate an interrupt (saying simply C function should be called lets say every 1 second) 
I created STM32 project CubeIDE+CubeMX  selected TIM3 (in Timers)  -> set Clock Source to InternalClock, set Prescaler ( PSC... ) to 8399 ( googled, found example ),
set Counter Period to 9999 and set NVIC checkmark for TIM3 (enabled)
 Saved IOC file and CubeMX generated some code for me.
In stm32f4xx_it.c file I added 

void TIM3_IRQHandler(void)
{
  /* USER CODE BEGIN TIM3_IRQn 0 */

  /* USER CODE END TIM3_IRQn 0 */
  HAL_TIM_IRQHandler(&htim3);
  /* USER CODE BEGIN TIM3_IRQn 1 */
  HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
  /* USER CODE END TIM3_IRQn 1 */
}

and running the code I expected to see blinking LED ( at least wanted no matter 1 sec or 0.5 sec )

but nothing happens
Did I miss something ? ( I'm learning this stuff )

 

12 REPLIES 12
Gyessine
ST Employee

Hello @Roman_E 
Hope you enjoy your time learning about timers
you can follow the steps of this article. It will help you learn how to do 1 second interruptions with timers
BR
Gyessine

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.

Thank you for your advice !
As I'm learning on how to use 4x4 keypad with F411re, I understand , that this interrupt function should be called periodically. Frequency it should be called based on Prescaler&Period ( at simple case + can be configured via CubeMX) 

htim3.Init.Prescaler = 8399;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 4499;

What would be your suggestion on "frequency to call the interrupt function" ?
I understand that in this function I need to add code "to scan 4x4 rows and columns". But how often this function should be called ? Every 10 ms ? 20ms?

I think your questions here - generating a timer interrupt - has now been answered?

Is so, please mark the solution on the post which provided the answer.

 

You already have a separate thread on 4 x 4 keypad with Nucleo 411RE and HAL, and @gbm has already given a suggestion for the scan rate there...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.