1
votes

I'm working on stm32f3 discovery board. For my current project I planned on coding a simple UART program on the board, I happened to read somewhere on the internet that to use the board for UART communication with PC the 'USER USB' has to be used.

My questions are the following

  • Firstly when i connect my board to PC using the 'USER USB'. The PC refuses to recognize the board.(F.Y.I- OS used is windows 7 64bit). This problem persists even after I update the driver! How to resolve this?
  • Is the "Connecting USER USB" part correct? because I can't see any RS232 chip on board
  • Should I use an add on board?

P.S I've installed all the necessary drivers from ST website and works flawlessly while using 'ST-Link interface' part of the board

2
Where do you get information about "USER USB"? may be they think that you need your own UART to USB converter.vlk

2 Answers

2
votes

Thanks for the post, had the same issue, here is what I added Approach: Turn-off USB lines programmatically by changing input to output, forcing it to zero and reenable them after around 1 second Also used power-off and on from ST USB Libs


// Force Re-Enumeration by the USB Host
//
int     aux_retrigger_usb()
{
        GPIO_InitTypeDef  GPIO_InitStructure;

        // ST USB Function
        PowerOff();

        // Program Pin 12 USB_DP from Input to Output
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

        GPIO_Init(GPIOA, &GPIO_InitStructure);
        // Set USB_DP to 0

        GPIOA->BRR  |= GPIO_Pin_12 ;

        // Wait for for minimum 32* 50msec ,  1,6 secs
        while(tim3_cnt%32!=0) ; while(tim3_cnt%32!=31) ;

        // ST USB Functions
        PowerOn();
        USB_Init();
        Virtual_Com_Port_Reset() ;

        // Program Pin 12 USB_DP from Output to input

        GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_12;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
        GPIO_Init(GPIOA, &GPIO_InitStructure);

        return 1 ;
}

So basically to avoid the power on race condition, the ports may be programmed first to outputs and then released after 1 second.

1
votes

I started working with the STM32F3 disco a few weeks ago. The user USB thing is a bit tricky. To get it clear: The board has 2 USB ports.

  • One mostly for programming and debugging. It connected to a second ST chip which works as programming adapter.
  • The seconds (called USER USB) is connected to the STM32F303 chips you program

So what you can do is to configure your STM32 to implement a CDC over USB. With the windows driver installed (automatic or from ST, depends on OS version) you should get a virtual com port in your device manager. If you don't have the driver, you also get a device labeled as virtual com port but with a yellow exclamation mark.

So if I get you question right, this is what you're trying to do? Then yes, "Connecting USER USB" is correct. No, you don't need an extension board.

How to resolve that? It depends: Do you already see the device in your device manager as communication device or serial interface or something? Then only the CDC driver from ST is missing.

Or do you get an "Unknown Device" in your device manager? That is what I experienced.

  1. In STM32CubeMX you need to enable the USB device (Peripehrals->USB)
  2. In STM32CubeMX you need to select the USB stack (MiddleWares->USB_DEVICE->Communication Device Class)
  3. Generate the code. If you are using HSI as clock source CubeMX will generate a error message you can ignore for now. For a real product you should use an external clock.
  4. Note that there is a bug in CubeMX version 4.20. The code generator generates code which may not work if you select HSE as clock input source. Even if you go back to HSI, the error remains.
  5. Compile an run the code. You maybe need to reset the board removing BOTH USB plugs
  6. Windows should detect the board now.
  7. Extra problem: The board is ... well. Tricky. If you only plug in the USER USB to your PC, it should work but Windows may also inform you that you have an UNKNOWN DEVICE because enumeration has failed.
  8. Remove the plug again. Now, first plug in the other, ST-LINK USB to power on the board. Wait 1-2 seconds. Now plug in the USER USB. There seems to be a startup problem. Only using the USER USB for power supply and CDC seems to run in a race condition between boot and USB and USB enumeration fails. First powering the board and then plugging in removes this race condition (at least at my board)

Now Windows should enumerate the device and offer you a virtual com port. Actually you should get two of them: One "ST... STLink Virtual COM Port" and one "ST... Virtual COM Port". The seconds one is the one you are looking for.

I hope that was the answer on the question you had.