cancel
Showing results for 
Search instead for 
Did you mean: 

Getting CAN error Frames due to USB OTG 48MHz HSE clock in custom bootloader

RDesh.1
Associate

Hi, I have a Nucleo F439ZI board and I am running a custom bootloader and application on it.

My Clock config =

  1. In Bootloader I am using HSE external crystal (ST-link MCO 8MHz) for all peripheral clock which includes 48MHz clock for USB OTG FS in DFU mode.
  2. In Application I am using HSI internal 16MHz oscillator for all peripheral clock and FreeRTOS.

When I jump from bootloader to application everything works good until I use the CAN bus. As I send the CAN frames from PC to Nucleo board using Kvaser and DCA2617A board, I see Error Frames randomly. If I increase the frequency of messages then the bus gets loaded with error frames only.

When I do the same CAN test without any changes in hardware and just one change in software -- change the custom bootloader clock to HSI internal -- then everything works perfectly fine and I don't see any Error Frames.

Can someone suggest what should I de-init in bootloader code before jumping to application.

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
RDesh.1
Associate

Thanks @TDK​ for responding to my question, I was able to resolve the issue. I found that when the PLL was being used to generate the peripheral clocks, I was getting the CAN error frames. I was not disabling the HSE in bootloader before jumping to application. I came across a similar post and observed that I need to DeInit the RCC unit and reconfigure it to default HSI source of 16MHz.

So I added the following line before jumping to application and everything worked afterwards.

HAL_RCC_DeInit();

View solution in original post

2 REPLIES 2
TDK
Guru

If you have an HSE clock source available, why not also use that for the application?

You can disable the HSE clock within the application to see if that helps. You'll need to do this after the clock source has switched off of it.

If you feel a post has answered your question, please click "Accept as Solution".
RDesh.1
Associate

Thanks @TDK​ for responding to my question, I was able to resolve the issue. I found that when the PLL was being used to generate the peripheral clocks, I was getting the CAN error frames. I was not disabling the HSE in bootloader before jumping to application. I came across a similar post and observed that I need to DeInit the RCC unit and reconfigure it to default HSI source of 16MHz.

So I added the following line before jumping to application and everything worked afterwards.

HAL_RCC_DeInit();