cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F373 USB prgram

JordiL
Associate II

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 

18 REPLIES 18
AScha.3
Principal III

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.

If you feel a post has answered your question, please click "Accept as Solution".
JordiL
Associate II

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

1.

Based on Cube, AF14

@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

You didnt tell which  board , usb hardware tested and working etc. -- so..?

+

Did you setup with cube usb-> device -> ??

If you feel a post has answered your question, please click "Accept as Solution".

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.

JordiL_0-1709460883369.png

Use same code with STM32F042 (but not config PA12/PA11 as alternate) and run properly.

Any Idea?

 

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.

> i can't change them [USB registers]

Usually that means, that you don't have all the needed clocks running.

JW

Thinks the same but theorically all clocks run as well

JordiL_0-1709462482655.png