Author Topic: STM32: F401CC Cube HAL USB Host & upcounting timer == hang  (Read 274 times)

0 Members and 1 Guest are viewing this topic.

Offline BennehBoy

  • Newbie
  • Posts: 3
  • Country: gb
STM32: F401CC Cube HAL USB Host & upcounting timer == hang
« on: April 20, 2021, 08:59:41 am »
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_HID

Ben
« Last Edit: April 20, 2021, 09:19:54 am by BennehBoy »
 

Offline BennehBoy

  • Newbie
  • Posts: 3
  • Country: gb
Re: STM32: F401CC Cube HAL USB Host & upcounting timer == hang
« Reply #1 on: April 20, 2021, 11:28:46 am »
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.
 

Offline BennehBoy

  • Newbie
  • Posts: 3
  • Country: gb
Re: STM32: F401CC Cube HAL USB Host & upcounting timer == hang
« Reply #2 on: April 21, 2021, 02:14:56 pm »
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.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 1464
  • Country: nl
Re: STM32: F401CC Cube HAL USB Host & upcounting timer == hang
« Reply #3 on: April 30, 2021, 05:22:44 pm »
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 Gay
ISBN-13 (pbk): 978-1-4842-3623-9
ISBN-13 (electronic): 978-1-4842-3624-6
https://doi.org/10.1007/978-1-4842-3624-6
Library of Congress Control Number: 2018945101

But 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.


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf