Hi,
I am trying to get a serial over usb connection on a stm32-h407 board on the usb micro connector (port OTG_HS).
I started with the demo ARMCM4-STM32F407-LWIP-FATFS-USB since that is for a very similar board (stm32-E407).
In the demo the usb serial is on port OTG_FS so I went ahead and switched the port in use in mcuconf.h
#define STM32_USB_USE_OTG1 FALSE
#define STM32_USB_USE_OTG2 TRUE
and then in main.c I set the usb driver to USBD2
static const SerialUSBConfig serusbcfg = {
&USBD2
};
After this changes the code seems to lock in
static void otg_core_reset(USBDriver *usbp) {
stm32_otg_t *otgp = usbp->otg;
/* Core reset and delay of at least 3 PHY cycles.*/
otgp->GRSTCTL = GRSTCTL_CSRST;
while ((otgp->GRSTCTL & GRSTCTL_CSRST) != 0) <------------------------- here
;
halPolledDelay(12);
/* Wait AHB idle condition.*/
while ((otgp->GRSTCTL & GRSTCTL_AHBIDL) == 0)
;
}
Am I forgetting to change any other board specific setting?
(the schematics of the usb port in question looks identical on the two boards)
Any suggestion about where I should start looking?
cheers
Renzo
USB serial on stm32-h407 newbie
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: USB serial on stm32-h407 newbie
Hi,
I suggest you start from the test application in ./testhal/STM32F4xx/USB_CDC, it is already defaulted to USBD2 and contains much less stuff not related to USB.
Probably your problem is related to differences in schematic, I suggest you create a new set of board files starting from those of the E407 and analyze pin by pin all the differences.
Giovanni
I suggest you start from the test application in ./testhal/STM32F4xx/USB_CDC, it is already defaulted to USBD2 and contains much less stuff not related to USB.
Probably your problem is related to differences in schematic, I suggest you create a new set of board files starting from those of the E407 and analyze pin by pin all the differences.
Giovanni
Re: USB serial on stm32-h407 newbie
for the records:
indeed the schematics revealed that the USB_HS_FAULT line is connected to a different pin on the h407 board.
However what was preventing things from running was the fact that the sleep time between disconnecting the usb bus and restarting it was not long enough, allowing half a second more does the trick:
Is that something common/expected?
I attached the h407 board.h file just in case it could be useful to someone.
cheers
Renzo
indeed the schematics revealed that the USB_HS_FAULT line is connected to a different pin on the h407 board.
However what was preventing things from running was the fact that the sleep time between disconnecting the usb bus and restarting it was not long enough, allowing half a second more does the trick:
Code: Select all
...
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(1500);
usbStart(serusbcfg.usbp, &usbcfg);
...
Is that something common/expected?
I attached the h407 board.h file just in case it could be useful to someone.
cheers
Renzo
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: USB serial on stm32-h407 newbie
That period seems to depend on the host speed, better increase it if in doubt.
Giovanni
Giovanni
Re: USB serial on stm32-h407 newbie
I am starting a project with the H407, so would be very interested in your board.h file (which I didn't see attached). Could you email me a copy, please?