cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 - FDCAN Interrupt not working

CSeif.1
Associate II

Hello,

i'm trying to set up a new project with CAN in Interrupt mode. Therefor i generate a project with stm32cubemx and enabled the interrupt 0 for fdcan1 and also in the NVIC-settings the Interrupt is enabled:0693W00000AN0JsQAL.pngIn polling mode, i can receive Frames and got no problems. When i try the to use the NVIC, the ISR-Adress is wrong an it don't jump to the generated "FDCAN1_IT0_IRQHandler". The Controller jumps to an undefined Adress:0693W00000AN0JxQAL.png 

In the startup_stm32l553cetx.s the spelling of the ISR is correct.

I've tried to get some more informations about the vector table. The ISR for fdcan_it0 should be in 0xbf900dc, the function of NVIC_GetVector gives me the Adress 0xbf97755.

Do you have any idea for a solution?

Greetings

1 ACCEPTED SOLUTION

Accepted Solutions
CSeif.1
Associate II

So, i get it working right now.

A deeper look in the hex files shows, that the interrupt table is based in the 0x8000000 Adress. So i added

 SCB->VTOR == 0x08000000;

This solved the problem.

View solution in original post

6 REPLIES 6
Ons KOOLI
Senior III

Hi @CSeif.1​ ,

Please refer to the STM32CubeL5 under Projects/$board_name$Examples/FDCAN

Best Regards,

Ons.

CSeif.1
Associate II

Hello @Ons KOOLI​,

thank you for your answer. I checked both files. I didn't use the globalfitler setting.

I try it on Monday and then i can give a feedack,

Best Regards,

Christoph

CSeif.1
Associate II

Hello @Ons KOOLI​ ,

i tried to get any interrupt working today but without success. Therefor i started with a new empty stm32cubemx project, selected the STM32L552CEx controller and enabled the fdcan1 with interrupt on line0 0693W00000ANA4xQAH.png 

After the code generation i've added the line for start and activate notifications:

HAL_FDCAN_Start(&hfdcan1);
  HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);
  __enable_irq();

Up there it worked. When i send a canframe from an external system i see an interrupt pending.

0693W00000ANAFRQA5.pngBut the controller don't enter the generated function from the cubemx

/******************************************************************************/
/* STM32L5xx Peripheral Interrupt Handlers                                    */
/* Add here the Interrupt Handlers for the used peripherals.                  */
/* For the available peripheral interrupt handler names,                      */
/* please refer to the startup file (startup_stm32l5xx.s).                    */
/******************************************************************************/
 
/**
  * @brief This function handles FDCAN1 interrupt 0.
  */
void FDCAN1_IT0_IRQHandler(void)
{
  /* USER CODE BEGIN FDCAN1_IT0_IRQn 0 */
 
  /* USER CODE END FDCAN1_IT0_IRQn 0 */
  HAL_FDCAN_IRQHandler(&hfdcan1);
  /* USER CODE BEGIN FDCAN1_IT0_IRQn 1 */
 
  /* USER CODE END FDCAN1_IT0_IRQn 1 */
}

So i called the rudimenary function HAL_Delay(10) after the init process from CubeMX. It entered the call but it stuck in this function in the while part

/**
  * @brief This function provides minimum delay (in milliseconds) based
  *        on variable incremented.
  * @note In the default implementation , SysTick timer is the source of time base.
  *       It is used to generate interrupts at regular time intervals where uwTick
  *       is incremented.
  * @note This function is declared as __weak to be overwritten in case of other
  *       implementations in user file.
  * @param Delay  specifies the delay time length, in milliseconds.
  * @retval None
  */
__weak void HAL_Delay(uint32_t Delay)
{
  uint32_t tickstart = HAL_GetTick();
  uint32_t wait = Delay;
 
  /* Add a period to guaranty minimum wait */
  if (wait < HAL_MAX_DELAY)
  {
    wait += (uint32_t)uwTickFreq;
  }
 
  while ((HAL_GetTick() - tickstart) < wait)
  {
  }
}

My guess is that something is wrong with the config of the interrupt vector table. VTOR gives me the baseaddress of the tabel, thats 0xBF90000. In the register starting from 0xBF90010, should be the addresses for the specific interrupt. The CAN ISR is the Block 0xBF900DC and thats not the function for the isr.

0693W00000ANAOxQAP.pngThis address jumps outside the code 0693W00000ANANbQAP.png 

It ends up by the error:

Break at address "0xbf97754" with no debug information available, or outside of program code.

I hope you can reproduce the problem or have any idea for the config of the isr table.

Best regards,

Christoph

CSeif.1
Associate II

So, i get it working right now.

A deeper look in the hex files shows, that the interrupt table is based in the 0x8000000 Adress. So i added

 SCB->VTOR == 0x08000000;

This solved the problem.

rohan_m
Senior

Where did you add the line ?

Sory if the question looks trivial but  I'm new into stm32.

Where sould I write this line of code?