[FIXED] STM32F103C8T6 USB problem
Moderator: RoccoMarco
[FIXED] STM32F103C8T6 USB problem
Not long ago I bought an STM32F103C8T6, and installed ChibiOS/RT on it. Nearly everything works fine (I used Olimex STM32P103 demo as a template for my project), but there's a problem with USB: on reset, it just hangs and doesn't react. Right there I asked a question about just the same thing, but with STM32F3Discovery. I was adviced to modify usb_lld_connect_bus and usb_lld_disconnect_bus. What should I do with usb_lld_connect_bus and usb_lld_disconnect_bus in this case to make it work?
Re: [FIXED] STM32F103C8T6 USB problem
I'm sorry, I have already fixed that. alexblack recommended me the right thing to do for all times
. I just used that code:
Code: Select all
#define USB_GPIO_PORT GPIOA
#define USBDM_BIT 11
#define USBDP_BIT 12
void usb_lld_disconnect_bus(USBDriver *usbp)
{
(void) usbp;
palClearPort(USB_GPIO_PORT, (1<<USBDM_BIT) | (1<<USBDP_BIT));
palSetPadMode(USB_GPIO_PORT, USBDM_BIT, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(USB_GPIO_PORT, USBDP_BIT, PAL_MODE_OUTPUT_PUSHPULL);
}
void usb_lld_connect_bus(USBDriver *usbp)
{
(void) usbp;
palClearPort(USB_GPIO_PORT, (1<<USBDM_BIT) | (1<<USBDP_BIT));
palSetPadMode(USB_GPIO_PORT, USBDM_BIT, PAL_MODE_INPUT);
palSetPadMode(USB_GPIO_PORT, USBDM_BIT, PAL_MODE_INPUT);
}
<snip>
//somewhere in main subroutine
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(500);
usbConnectBus(serusbcfg.usbp);