Hi all,
I try to make a device based on STM32L151 which will communicate through USB in CDC mode.
My software was initially developped on an STM32F4-discovery board, and it was working perfectly. It was also working on another board using a STM32F103. Then I switched to my own board and on STM32L-discovery and things started to go wrong...
If I compare stm32F and STM32L reference manuals, the only difference on the USB part is the internal pull up over D+ that you can manage via software (although it has been mentionned in an errata that the value was closer to 0.8kOhms than 1.5kOhms).
The electronic schematic of my board is pretty straightforward : D+ and D- of the STM32 are connected directly to a USB connector, no pullup. The entire board is USB powered.
I modified my working STM32F103 project for it fits the STM32L specs : * USB_LP_CAN1_RX0_IRQn renamed in USB_LP_IRQn * void USB_LP_CAN1_RX0_IRQHandler(void) in void USB_LP_IRQHandler(void) {
I use the same Keil RTX configuration on the other projects with USB working.
My clock settings are on HSE (driving an 8MHz quartz), with a PLL (PLLMUL12 thus PLLVCO @ 96MHz, PLLDIV2 thus SYSCLK = 48MHz), RTX SYSTICK_TIMER @ 72MHz. To be sure, I used MCO to display the SYSCLK frequency, divided by 2, and I measured 24MHz, which matched my expectations.
My main() starts a task that initialize I/O and USB as followed :
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//to manage internal usb pullup RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); os_tsk_prio_self(100); // Set task priority to medium usbd_connect(__TRUE); // USB Device Connect usbd_init(); // USB Device Initialization SYSCFG->PMC |= 1; //Set USB pull up (STM32 internal pullup) os_tsk_prio_self(1); // Set task priority to the lowest // Check if usb stack initialized and device connected to the host do { Delay(100); }while (!usbd_configured());
And my program is stuck in this loop.
On the PC side, my windows 7 see that some kind of USB device has been pluged as soon as the pull up is activated, but it prompts an error because it's unabled to retrieve VID and PID, so no driver assignation is possible.
I've worked with microchip PIC for a few years now, but I'm new to ST and Keil. Here I obviously miss something, but I can't simply put my finger on it.
Does somebody have any idea to make it work ?
Thanks in advance for your help.
Regards