USB is host-centric. Most, if not all, USB PC software has the PC as host. The host provides opportunity for you to send stuff to it. Your device can only respond. Your device can ask the PC to poll it every millisecond. If the host’s USB is very busy you may collect data you can’t send. This should not be a problem is the host is mostly dedicated to your application.

Looking at a project in which we need the stm32 to send data to the pc immedately when that data (adc) becomes available. We're looking at usb for this. The data is grabbed during a short pulse and then calculated and it is the results that we want to send to the pc. What we don't want is the pc continously asking for the info. As usb is new to me I'm trying to figure out how this would be done. One of the problems we have is that at the start of the pc software start we want to be able to pass data to the stm32. Is usb the way to go or are there more appropiate options, and if so how?

The host (pc) usb wont be busy at it only has the data from the stm32 to deal with. I'm more worried what will happen if the pc is polling the usb when the stm32 is working flatout on other tasks. This is why I wanted the the pc no to poll until the stm32 was ready to send. Thanks for the link and the answers so far. I'm sure if I keep reading I'll get the hang of this.

I think that the you could use the usb without issue foryour application.
In fact, as picguy said, the PC will always ask for data periodically (and you can configure the period lenth of course, min = 1ms).

- When the device has no data to send, it only sends a NAK (negative acknowledge) And this operation is done by hardware (no software needed to monitor the operation). So you risk nothing and your process won't be slowed down.

- If the device has many data to sent within the frame (1 ms), (that means the data sampling frequency is higher than the max host polling frequency), then the device can send all the samples available at that moment to the host in a single packet. And thus no data is lost.

I’m early in the process of writing a custom HID application. So early that what I am to say next is only an educated guess.

The setup: You have just sent data to the host. You will not be ready to send anything else for several milliseconds. But you told (asked, really) the host to accept data every millisecond.

The educated guess: The host asks for data. The STM32 USB engine responds “not now.” Your code is not bothered. I.e. you remain unaware of the poll and its automated response.

FYI: on another processor (PUC 18F...) using a hardware debugger it appeared that I was able to send data to the host (Win XP) with no application program taking the data. Thus if you want to know if/what data was lost include a sequence number.