I am setting up a simple USB device with the STM32F429ZI using a nucleo-f429zi devkit. I need to use the high speed peripheral in full-speed mode. I have a simple test program setup with the dev-kit that I am using.
main.cpp
#include "mbed.h"
#include "USBKeyboard.h"
#define DEV_VID 0x1235
#define DEV_PID 0x0050
#define DEV_RELEASE 0x0001
USBKeyboard _keyboard(false, DEV_VID, DEV_PID, DEV_RELEASE);
void PeriodicUpdate()
{
_keyboard.connect();
ThisThread::sleep_for(1s);
if( _keyboard.ready() )
{
_keyboard.printf("Hello from USB!\r\n");
}
}
int main()
{
printf("Start App...\r\n");
while(1)
{
ThisThread::sleep_for(5s);
PeriodicUpdate();
}
}
appconfig.json
{
"target_overrides": {
"*": {
"mbed-trace.enable": false,
"platform.stdio-baud-rate": 115200,
"platform.stdio-buffered-serial": 1,
"target.components_add": ["FLASHIAP", "SPIF"],
"target.clock_source": "USE_PLL_HSE_XTAL|USE_PLL_HSI",
"target.printf_lib": "std",
"target.usb_speed": "USE_USB_OTG_FS",
"rtos.main-thread-stack-size": 8192,
"rtos.idle-thread-stack-size": 4096
}
}
}
build command
mbed compile -m NUCLEO_F429ZI --profile debug -N software --color --app-config=./appconfig.json --build=BUILD/software/NUCLEO_F429ZI/debug --artifact-name software
I have run the above program and it works just fine using the USE_USB_OTG_FS configuration. This is the default USB port on the Nucleo Dev-kit.
My next goal is to use the HS USB port in Full speed mode. I rebuild the project with the following configuraiton.
{
"target_overrides": {
"*": {
"mbed-trace.enable": false,
"platform.stdio-baud-rate": 115200,
"platform.stdio-buffered-serial": 1,
"target.components_add": ["FLASHIAP", "SPIF"],
"target.clock_source": "USE_PLL_HSE_XTAL|USE_PLL_HSI",
"target.printf_lib": "std",
"target.usb_speed": "USE_USB_HS_IN_FS",
"rtos.main-thread-stack-size": 8192,
"rtos.idle-thread-stack-size": 4096
}
}
}
I have soldered on a USB tail to the USB HS port on the nucleo. The device fails to enumerate when plugged into the PC. It shows up as a failed USB device.
I have validated the connections are correct and use the default pinout as defined in the “PinMap_USB_HS” by generating a CubeIDE project for the devkit with the USB device HS configured in FS mode. When I connect the device to my PC with the CubeIDE generated project, the device enumerates.
MBED_WEAK const PinMap PinMap_USB_HS[] = {
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_HS_IN_FS)
// {PA_4, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF // Connected to VSYNC
{PB_12, USB_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID // Connected to OTG_HS_ID
{PB_13, USB_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS // Connected to VBUS_HS
{PB_14, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM // Connected to OTG_HS_DM
{PB_15, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP // Connected to OTG_HS_DP
#else /* MBED_CONF_TARGET_USB_SPEED */
Has anyone successfully used this on an STM32 nucleo and does anything I am doing here explain why this is failing?