We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi!
First of all until now I have used the STM32F103 with an own schematic. Now I have to migrate my "old" project to the new STM32F412G DISCOVERY - Board. As i understood with the USB-Device-API of KEIL-DFP (CMSIS-Driver) I can develop an USB-Communication which is abstracted from hardware, so my code can be easily migrated to a new µController - only by replacing the µC-Device in Keil-µVision.
I migrated already many parts but I'm not able to run the USB-Device. So what have I tried until now?
First I tried the HID-Demo application from ST "STM32Cube_FW_F4_V1.16.0" this is working -> there should no hardware issues at the discovery-board (like broken connections). But as explained I need Keil's USB-API of DFP. So I opened the example projects via keil "Pack Installer" for the "MCBSTM32F400" and the "STM32f429I-Discovery". I have checked the schematics of both boards -> both boards have an "user USB" connector using USB-OTG-FS with pins PA9 to PA12 -> like the STM32F412G DISCOVERY.
For STM32F412G DISCOVERY I can't use the "board support", which means "Button" and "LED", of the example projects will not work, but they are not mandatory for basic USB communication.
Steps: 1. opening USB-Device-HID example of MCBSTM32F400 / STM32f429I-Discovery 2. changeing device to STM32F412ZGTx 3. changeing HSE_VALUE and Xtal to 8000000 4. disable OTG HS driver - because not available at STM32F412ZGTx 5. configured RTE_Device.h - enabled USB-OTG-FS - Device + VBUS sensing pin 6. disabled "board support" with Buttons/LED and removed this from code lines 7. added the "stm32f4xx_ll_fsmc.c" to project 8. changed the RTX clock to 100MHz 9. finally changed the systemclock settings as specified in the "STM32Cube_FW_F4_V1.16.0" example
void SystemClock_Config(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; HAL_StatusTypeDef ret = HAL_OK; /* Enable Power Control clock */ __HAL_RCC_PWR_CLK_ENABLE(); /* The voltage scaling allows optimizing the power consumption when the * device is clocked below the maximum system frequency, to update the * voltage scaling value regarding system frequency refer to product * datasheet. */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /* Enable HSE Oscillator and activate PLL with HSE as source */ 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 = 8; RCC_OscInitStruct.PLL.PLLN = 200; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 7; RCC_OscInitStruct.PLL.PLLR = 2; ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); if (ret != HAL_OK) { while (1) {; } } /* Select PLLSAI output as USB clock source */ PeriphClkInitStruct.PLLI2S.PLLI2SM = 8; PeriphClkInitStruct.PLLI2S.PLLI2SQ = 4; PeriphClkInitStruct.PLLI2S.PLLI2SN = 192; PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CK48; PeriphClkInitStruct.Clk48ClockSelection = RCC_CK48CLKSOURCE_PLLI2SQ; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 * clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | 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; ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); if (ret != HAL_OK) { while (1) {; } } }
Then i compiled without errors and flashed the target successfully - but after reset the usb-device is doing anything. Normally you get the windows "usb plugin sound" or you can see a new device in the hardware manager, but there happens nothing. If you have a misconfiguration, you will get an error notification from windows -> also nothing. It looks like there is any usb communication. I also check the usb cable - it has data lines and as i mentioned it is working with the "STM32Cube_FW_F4_V1.16.0" example.
So what I'm doing wrong? where is my mistake?