2024-03-02 10:02 AM
Hi, two questions:
1.- What config must set to PA11/PA12 pins? I set ALTERNATE FUNCTION (0x10) in MODER register, but what AF option must set? In STM32F373 manual there is no AF defined.
2.- I configure USB device (clocks/gpio) and i can access to USB registers as ADDR,... but EPs seems inhibed? you know the reason why?
Thanks a lot
2024-03-02 10:18 AM
Hi,
Why dont you use CubeMX and set USB -> device ...etc. there ?
Even if you prefer to just write bare metal to registers yourself, look at the generated code and you see, what you need to do.
2024-03-02 12:44 PM
I did but have same result,
MX_USB_PCD_Init();
HAL_PCD_EP_Open(&hpcd_USB_FS, 0, 64, EP_TYPE_CTRL);
but EP0 no change values. EP0 -> 0x00.
I write bare metal and use debug (CUBEide) and i can't modify the Eps
2024-03-02 12:53 PM
1.
@Imen.D, this information is missing from the 'F373 DS Alternate functions for port PA table, can it please be fixed?
2.
> i can access to USB registers as ADDR,... but EPs seems inhibed?
How do you know?
JW
2024-03-02 01:00 PM
You didnt tell which board , usb hardware tested and working etc. -- so..?
+
Did you setup with cube usb-> device -> ??
2024-03-02 01:15 PM
Hi @JordiL ,
It's recommanded to refer to ST applications demo in STM32CubeF3 for the clock and init of USB.
please see here STM32373C_EVAL USB pin configuration
and the USB clock config:
2024-03-03 02:17 AM
1- Set PA12/PA11 -> Alternate function / High Speed / AF14
GPIOA->MODER = GPIOA->MODER | 0x02800000;
GPIOA->OSPEEDR = GPIOA->OSPEEDR | 0x03C00000; //Pins PA12-PA11 -> High speed
GPIOA->AFR[1] = GPIOA->AFR[1] | 0x000EE000; //Pins PA12-PA11 -> AF14 USB pins !!!!!
2- Set USB clock enable
RCC->APB1ENR = RCC->APB1ENR | 0x00800000; // enable USB clock
3- Clean USB Registers
USB_REG->CNTR = USB_REG->CNTR & 0xFFFD; // Clear PWND bit
//wait 1uS
HAL_Delay(1);
USB_REG->CNTR = USB_REG->CNTR & 0xFFFE; // Clear FRES bit
USB_REG->ISTR = 0x0000; // Clear spourious interrupts
4- Set USB->ADDR = USB->ADDR | 0x80; //Enable device
Theorically, now USB is ready to accept configure the EPns. But when i try to do it i can't change them.
Use same code with STM32F042 (but not config PA12/PA11 as alternate) and run properly.
Any Idea?
2024-03-03 02:19 AM
Use STM32373-Eval board in order to develope a USB driver.
If generate code with CUBEmx i have the same problem as if i write my own code.
2024-03-03 02:32 AM
> i can't change them [USB registers]
Usually that means, that you don't have all the needed clocks running.
JW
2024-03-03 02:41 AM
Thinks the same but theorically all clocks run as well