STM32: F401CC Cube HAL USB Host & upcounting timer == hang - Page 1
Forum section: electronics / general

author: BennehBoy
author_rank: Newbie
timestamp: April 20, 2021, 08:59:41 am
content: Hi,New to the forum so apologies if I've stomped on any etiquette.Anyhow, I'm not so new to stm32 but have been firmly sat in the Arduino camp using STM's Arduino core & previously Roger Clarke's libmaple based core.Because neither of these have a working USB Host HID implementation I decided to take the plunge and try and implement my project using Cube IDE.Essentially I'm converting USB HID Mouse reports to Amiga quadrature GPIO outputs. All of the code for this is working within cube.However, I need to accurately shape the quadrature waveform and it seemed to me that using a hardware timer would be the obvious way to achieve this with some accuracy.As soon as I enable the timer the MC appears to hang (I'm not sufficiently familiar with Cube to use the debugger yet), this observation is based on the fact that I do not see any GPIO changes when mouse input occurs, and the serial debug messages that were being written successfully prior to the timer inclusion also cease.I've pared the code right back to only include the timer & serial output (ie no USB) and the timer works flawlessly along with output appearing in the serial console - adding a GPIO toggle based upon this timer also results in the expected frequency waveform on the GPIO pin.My best guess is that I've inadvertently stumbled into some interrupt lock/race condition, but after googling like mad and poring over the 401CC reference I can't see anything obvious.The board I'm using is a WeAct STM32F401CCU Development board (Pill based layout). It's the older board with boot0/1 jumpers and not the push buttons.Any help/suggestions would be gratefully accepted.EDIT - code here ->https://github.com/BennehBoy/F401_AMIGA_HIDBen

author: BennehBoy
author_rank: Newbie
timestamp: April 20, 2021, 11:28:46 am
content: Been familiarising myself a little with the debugger.So the MCU is not locked, it is sat executing the main loop. I've inserted an LED blink in there using a HAL_Delay and the LED flashes.My eventhandler for the USB HID callback is not being invoked when I have a TIMER configured.I guess I need to go and read the reference manual thoroughly.

author: BennehBoy
author_rank: Newbie
timestamp: April 21, 2021, 02:14:56 pm
content: For anyone interested, I resolved this by switching to using DWT for the delays.Not sure if this was the root cause however since the board I was testing on got the USB circuitry fried - have not gone back and tried timer delays on the replacement. So could have been user error.Updated code in the repo linked.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: April 30, 2021, 05:22:44 pm
content: I have had success with compiling, flashing and running the serial CDC example from sathosimn.I also quite like the book:Beginning_Developing_with_FreeRTOS_libopencm3_and_GCC by Warren GayISBN-13 (pbk): 978-1-4842-3623-9ISBN-13 (electronic): 978-1-4842-3624-6https://doi.org/10.1007/978-1-4842-3624-6Library of Congress Control Number: 2018945101But I have to admit. I have not ran his USB serial example.Just a few days ago I also compiled, flashed and ran grblHAL for the WeAct STM32F411, and communication with bCNC works over USB.