cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743, USB2 SOF events happen normally or at twice the expected rate.

BKlus.1
Associate III

I have designed an audio device based on a STM32H743 MCU. For synchronization purposes I need to be able to count incoming USB frames.

To achieve this, I use TIM5 in slave mode, with ITR8 as its trigger.

The results are puzzling. I am getting either 1000 SOFs per second (as expected) - or 2000.

The behavior is specific to a particular MCU. I have 12 boards, all running the same code. Five count SOFs correctly and seven at twice the expected rate. Reflashing a MCU, even after a full chip erase, makes no difference.

The markings on all the processors are identical.

What might be going on? Any ideas?

9 REPLIES 9

> To achieve this, I use TIM5 in slave mode, with ITR8 as its trigger.

Read out and post TIM5 registers content.

How are you determining the count per second?

JW

TIM5 registers attached. The values are identical in both sets of boards.

I have a ThreadX task, with a 50ms period loop. In each iteration, I read TIM5 CNT and compare it with the previous value. The results I am getting are either 50 (as expected) or 100.

If you stop execution and look at TIM5_CNT in debugger, refreshing it roughly once per second, do you see the same difference in increments on two different boards?

(In other words, I doubt your ThreadX task does what you describe or that executes once every 50ms in both cases. By using debugger and your own eyes, a whole bunch of software layers is excluded

An even better test would be to set up TIM5 to perform PWM one some of the TIM5_CHx and observe using oscilloscope/LA, if you have such pin available).

JW

I made the task blink a LED every second (10 periods on, 10 periods off) and there is no difference between the boards. I also made the boards output (over a USB serial port) the TIM5->CNT register every period, and sure enough, one increments 1000 per second and the other - 2000.

Identical boards, built by the same assembly house in the same batch, running the same code.

This is a mystery.

Both (all) devices are connected to the same port of the same host (PC)? Can you try if when connected to a different host (e.g. Linux PC) devices behave the same?

Can you please read out and check in perhaps similar manner (i.e. sending it through USB) content of OTG_DSTS.FNSOF of given USB module?

JW

Same port of the same host. I don't have a Linux host handy right now, but can probably find one later if I have to.

I tried reading the FNSOF field. Well, this is interesting. FNSOF is incrementing at the expected rate on all boards. The timers are still incrementing at either exactly that rate or double the rate.

Well, at least this gives me an elegant way to program around the problem. I will just use FNSOF instead of the timer. I will have to read it often enough to handle the counter wrapping, but that's not a big problem.

Thank you for looking at this!

In that case this sounds much like a hardware error.

@Amel NASRI​ , can this please be checked.

Thanks,

JW

Piranha
Chief II

Straight from a crystal ball - are you using HSE, what is connected to it and is a bypass enabled?

I am using HSE, 8 MHz crystal (ABM2-8.000MHZ-D4Y-T), bypass disabled.