9 years, 11 months ago.

How to get the USBDevice library to work with ST Nucleo F401?

Tomas,

I am very new to mbed and trying to achieve USB communication with the Nucleo F401 and am wondering where to add your clock fix. I'm seeing in the USBDevice library files for the KL25Z, LPC11U, and LPC17. Did you create your own file for the F401 or did you modify one of these to suit.

Also how did you get around the "Unknown target type" "#error"

Thanks!

Question relating to:

USB device stack with Nucleo F401RE support. NOTE: the default clock config needs to be changed to in order for USB to work. device, Nucleo, USB

1 Answer

9 years, 11 months ago.

If you just want serial communication it would be easiest to Serial pc(SERIAL_TX,SERIAL_RX). Although I had many problems with serial communication through the STLink interface.

The unknown target error probably means that your are not actually compiling with my fix. Here's how the file structure should look in the online IDE:

/media/uploads/tolaipner/usbdevice_file_structure.png

Regarding the clock settings, I changed mine directly in the targets/hal/TARGET_STM/NUCLEO_FR.../rtc_api.c file. But I suspect they could be changed in your main() function. Extract from my rtc_api.c file (with original lines commented out):

    // Enable LSI clock
    RCC_OscInitTypeDef RCC_OscInitStruct;
    /*RCC_OscInitStruct.OscillatorType =  RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
    RCC_OscInitStruct.LSIState = RCC_LSI_ON;
    RCC_OscInitStruct.LSEState = RCC_LSE_OFF;*/
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
    RCC_OscInitStruct.HSIState = RCC_HSI_ON;
    RCC_OscInitStruct.HSICalibrationValue = 16;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
    RCC_OscInitStruct.PLL.PLLM = 16;
    RCC_OscInitStruct.PLL.PLLN = 336;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
    RCC_OscInitStruct.PLL.PLLQ = 7;
    if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
        error("RTC error: LSI clock initialization failed."); 
    }

Accepted Answer

Assigned to Tomas Cerskus 9 years, 11 months ago.

This means that the question has been accepted and is being worked on.