cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F302CB Problems with USB

Andriy Mark
Associate II
Posted on April 05, 2018 at 12:22

Hi,

I'm trying make USB custom HID with stm32f302CB. I'm using Keil v5.23 and STM32CubeMX. The problem:

PC just don't recognize the USB, when i running in debug mode i saw something strange. Just after calling HAL_PCD_Init interrupt executing. In HAL_PCD_IRQHandler from there we go to HAL_PCD_ResetCallback. Thet calbek must config USB_EP0R register to config default endpoint. It perform by HAL_PCD_EP_Open. Ther are macros PCD_SET_EPTYPE thet write in USB_EPnR  but in peripheral viewer they doesnt change. It's strange because others USB registers are writing normally. I'm trying write UART_EP0R by my own but it's doesn't work either. In RCC_APB1ENR USBEN is set.

0690X0000060ARLQA2.png0690X0000060ARQQA2.png0690X0000060ARVQA2.png0690X0000060ARpQAM.png

Im trying to create same USB HID on STM32F407 Discovery with Keil and CubeMX and it works fine. 

Does someone have an idea where the problem could be?

1 ACCEPTED SOLUTION

Accepted Solutions
Andriy Mark
Associate II

I find my problem. I was using some non recommended crystal ceramic resonator. Interesting that crystal ceramic resonator was generate swings and even my UART working on defined frequency. I think there was little frequency deviation and it was acceptable for UART but too big for USB.

View solution in original post

4 REPLIES 4
Posted on April 06, 2018 at 07:58

Ther are macros PCD_SET_EPTYPE thet write in USB_EPnR  but in peripheral viewer they doesnt change. It's strange because others USB registers are writing normally. I'm trying write UART_EP0R by my own but it's doesn't work either. In RCC_APB1ENR USBEN is set.

Look into the RM - some bits in this registers are rc_w0, which means you cannot write them to 1; others are t, which means that writing 0 has no effect and writing 1 toggles its value.

Your problem will be most probably somewhere else.

JW

Posted on April 06, 2018 at 10:56

Thanks for You'r advise but in reference manual in registers USB_EPnR are two rw bits EP TYPE that I traying to set, and it's doesnt work.

Posted on April 07, 2018 at 15:43

I know it's not in the RM, but I guess those bits are locked when the channel is enabled.

JW

Andriy Mark
Associate II

I find my problem. I was using some non recommended crystal ceramic resonator. Interesting that crystal ceramic resonator was generate swings and even my UART working on defined frequency. I think there was little frequency deviation and it was acceptable for UART but too big for USB.