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 17, 2021
 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_DIV4;
 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);
}

After some more measuring i know my HSE is running at 8MHz.

The device shows up in the Device list so i am getting a 48MHz clock on my USB perpherial.

Just my main while wont start i and have now clue why, is this related to clock as well ?

TDK
July 19, 2021

> Just my main while wont start i and have now clue why

Debug it, hit pause, see where the code is stuck.

Ensure Error_Handler has something inside of it so you know when calls fail.

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

Looks my ADC1 was hanging my MCU.

I added a counter to my while loop and after just a few counts the counter stopped.

By commenting out functions one by one and run the debugger i noticed the program just run fine with the ADC initialization commented out.

It seems like my

hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2

was to fast and changed it into

hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8

But why did this happen i couldn't find a exploitation for, yeah it runs but i just need to know why and learn from it.

While loop is running now , just to need program my code again step by step and see if there are more bugs.

Is there a simple guide somewhere on how to do proper debugging?