Skip to main content
MHovi.1
Associate II
July 8, 2021
Question

Transfer from STM32f411RE to STM32F411ce

  • July 8, 2021
  • 15 replies
  • 2858 views

Hi there,

Recently if done a project regarding custom hid on a STM32F411RE Nucleo prototype board, this was successful. I have created my own pcb design but unfortunatly due the lack of availability of the STM32F411RE i was forced to go with the STM32F411CE QFN48. Adapted my board design and after populating my newly received boards i run into a snag. I adapted my original code to the 411CE alas its not popping up in my windows device list as a custom HID device. But it does show in DFU mode , i can upload my code through ST LINK. Debugger in CUBEIDE works fine. Just to keep it simple i made a bare project which only use the custom HID options out of CUBE IDE. Does behave exactly as described, but not showing up as Custom HID Device.

Might be a bit short sighted but i think it is not my PCB design,cause of the above behavior.

Maybe someone in here has some experience with the F411CE and can put me on the right track.

Thanks in advance.

This topic has been closed for replies.

15 replies

MHovi.1
MHovi.1Author
Associate II
July 8, 2021

Did some more testing/measuring.

SPI clock and chip select works fine. All connection seems to be as designed.

ADC is working, I can see it in live expressions in the debugger.

In ST link the device gets detected and reads the memory.

Still got the impression it's not the PCB.

Tried to upload a simple keyboard hid code.

Code gets compiled and flashed in the mcu, but doesn't show up as hid keyboard.

I'll try a simple led blink code tomorrow.

​

​

Tesla DeLorean
Guru
July 8, 2021

The HSE starts properly? Frequency matches HSE_VALUE? PLL's start/clock as expected? Check use MCO/PA8

The Nucleo pulls an 8 MHz source from the ST-LINK

If you pull BOOT0 High, does System Loader come up as a USB DFU / STM32 BOOT LOADER type device?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MHovi.1
MHovi.1Author
Associate II
July 9, 2021

Hi Tesla,

Yes it shows up as a STM32 BOOT LOADER device.

TDK
July 9, 2021

There's nothing dramatically different between these chips. Code that works on one should generally work on the other without modification. If the USB DFU bootloader works correctly, there is probably a bug in your program.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MHovi.1
MHovi.1Author
Associate II
July 10, 2021

Update,

Just came to the conclusion the 4 pad crystal wasn't correctly placed, it was 180 rotated. I couldn't see where the pin 1 of the crystal was located so i just swapped it.

I made a quick Custom HID program and it worked.

After this correction my device works as designed. Thanks Tesla to pointing me to the clock.

TDK,

Unfortunately my original program didn't work on the F411CE , don´t know why jet but will tru to figure it out over the weekend.

Thanks for the help this far.

MHovi.1
MHovi.1Author
Associate II
July 11, 2021

I have been trying but no luck.

Tested the project on my nucleo with f411 re ,zero issues.

Looks like I have to start from the ground up again and debug it step by step to see what's going on.

​

MHovi.1
MHovi.1Author
Associate II
July 12, 2021

I have been Checking my HSE clock again on the RCC_MCO1 pin the output is 16.13 MHz , but USB custom HID needs 48 MHz. So something is of.

I configured the clock options through cube ide.

Been reading through datasheet of the F411 and some articles about crystals.

But to my knowledge i have done the setup right, maybe someone see an error

The code generated by cube ide below.

Hopefully someone could push me in the right direction.

void SystemClock_Config(void)
{
 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
 /** Configure the main internal regulator output voltage
 */
 __HAL_RCC_PWR_CLK_ENABLE();
 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
 /** Initializes the RCC Oscillators according to the specified parameters
 * in the RCC_OscInitTypeDef structure.
 */
 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
 RCC_OscInitStruct.PLL.PLLM = 4;
 RCC_OscInitStruct.PLL.PLLN = 72;
 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
 RCC_OscInitStruct.PLL.PLLQ = 3;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 {
 Error_Handler();
 }
 /** Initializes the CPU, AHB and APB buses clocks
 */
 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 
 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
 {
 Error_Handler();
 }
}

and the clock config in Cube ide

0693W00000BdTgNQAV.jpg0693W00000BdTeCQAV.jpg

MHovi.1
MHovi.1Author
Associate II
July 13, 2021

Banging my head on the keyboard here;)

My while loop doesn't run, so i suspect my oscillator isn't starting. My ADC does run but seems like ADC is not clock dependent.

Does the HAL layer work regarding clock settings?

If i select HSI i can measure the 16 MHz freq.

Just for future pcb design, is the LSI mandatory or can it be left out of the design.(for now it will be only a USB custom hid board).

Some help will be appreciated.

Thanks

0693W00000BdaxVQAR.png

TDK
July 13, 2021

> I have been Checking my HSE clock again on the RCC_MCO1 pin the output is 16.13 MHz

Certainly seems like it's using HSI and not HSE. Does Error_Handler get executed? Put something in there so calls do not silently fail.

What crystal are you using? 5pF seems low.

> Just for future pcb design, is the LSI mandatory or can it be left out of the design.

The LSI is internal to the chip. The LSE (low speed external crystal) is optional.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MHovi.1
MHovi.1Author
Associate II
July 13, 2021

TDK, I meant LSE.

I use a ​abm3b-8.000mhz-10-1-u-t oscillator

And I will recheck my capacitors

Thanks for the error handler sugestion I'll give it a try tomorrow.

MHovi.1
MHovi.1Author
Associate II
July 14, 2021

I swapped the capacitors to 10pF.

The F411 mco1 pin allows HSE,HSI,LSE and LSI measurement only, there is no mco2(pc9) pin on this qfn48 package so i cant measure the sysclk other package have this ability.

I can confirm 8 Mhz clock on mco1, so the crystall seems to be running, is there another way to measure the sysclock just to confirm it is working?

Just noticed the following,

If line 14 is commented my while loop is running i can measure my HSE, but my device is not showing up as Custom HID device.

If line 14 is uncommented my while loop does not run and i can measure my HSE but my device DOES shows up as Custom HID device.

So my tought is in the first option is the 48MHz clock is not getting started.

void SystemClock_Config(void)
{
 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
 /** Configure the main internal regulator output voltage
 */
 __HAL_RCC_PWR_CLK_ENABLE();
 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
 /** Initializes the RCC Oscillators according to the specified parameters
 * in the RCC_OscInitTypeDef structure.
 */
 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 //RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
 RCC_OscInitStruct.PLL.PLLM = 4;
 RCC_OscInitStruct.PLL.PLLN = 72;
 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
 RCC_OscInitStruct.PLL.PLLQ = 3;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 {
 Error_Handler();
 }
 /** Initializes the CPU, AHB and APB buses clocks
 */
 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 
 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
 {
 Error_Handler();
 }
 HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
}

Are there more parameters to check?

TDK
July 14, 2021

If you specify OscillatorType = RCC_OSCILLATORTYPE_HSI, you need to specify a value for HSIState. And if it's currently used for the PLL, it can't be off. Same for HSE. You can't just comment those out. Use CubeMX to generate clock settings or read documentation in the function headers.

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