cancel
Showing results for 
Search instead for 
Did you mean: 

Impossible to get USB device and sequencer working together

XPonc.1
Associate III

Hello ST Community,

Let's start with my problem:

I have a STM32WB55CG chip that I want to get working in BLE. I also want it to have an USB CDC interface.

I created a project on cubeMX, added my external oscillator (32MHz), activated the USB device under "connectivity", then the Communication Device Classs under "MiddleWare". I went to generate this project, compile under Keil and program my chip. Connected it to my PC, seems to work, Windows recognizes it as COM3. Note that my project is still blank at this point, I did not write a single line of code.

Then back to CubeMX, I added the Bluetooth part: HSEM in "System Core", RTC in "Timers", RF in "Connectivity", STM32_WPAN in "MiddleWare". That last option added automaticaly "Sequencer" and "Tiny_LPM" in "Utilities" (I would've added them anyway).

Code generation, but this time Keil (my IDE) gives me errors: CubeMX generated some files 2 times in my project, see below.

I get it compiing, and program my chip. This is STILL a blank project: the only lines of code I have in my project are the one generated by CubeMX.

This time the USB does not work: Windows gives me an "unrecognized device" error. Diving in he could not get descriptor.

Do you have any idea how to correct this?

Thanks,

Xavier

---------------------------------

The bug-report part (nothing too serious I think):

On another (hopefully unrelated) note: CubeMX seems to generate projects that does not compile, at least with Keil IDE. The cause of this is because it generates 2 times the files 'dbg_trace.c", "otp.c", "stm_list.c" and "stm32_seq.c", once under the folder "Utilities" and once under the folder "Middlewares/STM32_WPAN".

I also noticed that the frequency of "RFWKP" seems to be incorrect: I have a 32MHz HSE input oscillator, and the GUI of CubeMX says that once it's divided by 32, the freq is... 31.25 kHz? Is it a bug or did I miss something?

1 ACCEPTED SOLUTION
3 REPLIES 3
XPonc.1
Associate III

Hello again everyone.

I managed to get the blank project working, I forgot that I neeeded to declare the IRQHandler for RTC interrupt.

The USB still works when I init the sequencer using "UTIL_SEQ_Init();".

However, the USB does not work when I use the "UTIL_SEQ_Run(~0);" function... Does the critical sections in the sequencer a problem for USB?

I keep investigating, but if any of you has an idea, I'll get it.

Thanks,

Xavier

XPonc.1
Associate III

I investigated further. The USB does work when I comment "TaskCb[CurrentTaskIdx]( )" in "UTIL_SEQ_Run(~0);".

I dived a bit with the debugger. We go into a function called "shci_user_evt_proc". Everything seems fine and we dive into the function "APPE_SysUserEvtRx" called by the line n°135 "shciContext.UserEvtRx((void *)&UserEvtRxParam);"

This function calls "APP_BLE_Init" which calls "Adv_Request(APP_BLE_FAST_ADV);" . The problem then seems to be in "HW_TS_Start(BleApplicationContext.Advertising_mgr_timer_Id, INITIAL_ADV_TIMEOUT);".

In this function (file hw_timerserver.c) I go in a critical section (line 814) and I am blocked in it (line 834, function "RescheduleTimerList();"). So now I get why USB doesn't work (as I am stuck in a critical section with all interrupts disabled), but I still don't knwo why I am stuck....

I keep going into the code deeper and deeper:

in "RescheduleTimerList();" I call "RestartWakeupCounter(wakeup_timer_value);" and I get stuck at line 358 of "hw_timerserver.c": "while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(phrtc, RTC_FLAG_WUTWF) == RESET);"

I will look into it, why is this flag never set.

Thanks,

Xavier