2016-03-09 06:55 AM
Hi All,
I'm working on a STM32F429-based USB HighSpeed peripheral which exchanges MIDI data with a host computer.If you're not familiar with MIDI, don't worry about it - just know that in the land of USB it's represented as 2 x bulk endpoints. In a nutshell - the problem I'm seeing is that sometimes the STM32 fails to provide a handshake packet (NAK, ACK, or otherwise) in response to a OUT packet to the incoming bulk endpoint of the device. I'm reaching out to see if anyone has experienced a similar issue, hopefully with a workaround/solution. My configuration is as follows:I'm looking at the trace from a USB protocol analyzer and can see the following series of events:
It's worth noting that this problem does not occur if I use either the USB-FS core of the USB-HS core with on-chip FS PHY. But this is at a significantly data rate.
The only other ISR running in the system is SysTick, and it's as low as a priority as it can get. I'm not currently do anything with the incoming data. I'm merely trying to test the raw transfer speed. My ''_DataOut'' handler within the USB ISR is very simplistic.The MIDI data handler within is simply a stub at this point.uint8_t usbd_MIDI_DataOut(
void
*pdev, uint8_t epnum)
{
// ------------------------------------------------------------------------
// Determine how many bytes have been received and handle them
// Note: USB should NAK until endpoint is re-prepared for new reception
// ------------------------------------------------------------------------
uint32_t rx_count = ((USB_OTG_CORE_HANDLE *)pdev)->dev.out_ep[epnum].xfer_count;
usbd_MIDI_RX(rx_buffer, rx_count);
// ------------------------------------------------------------------------
// Re-Prepare the OUT endpoint to receive the next packet from the host
// uint32_t DCD_EP_PrepareRx(USB_OTG_CORE_HANDLE *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t buf_len)
// ------------------------------------------------------------------------
DCD_EP_PrepareRx(pdev, midi_driver_config.base_ep_out, rx_buffer, MIDI_EP_SIZE);
return
USBD_OK;
}
void
usbd_MIDI_RX(uint8_t* buffer, uint32_t len)
{
// ReadUsbRcvdData(buffer, len);
}
The USB trace is seen below.
#ulpi #usb #stm32f4
2016-03-09 01:01 PM
Follow-Up interesting testing result - simplifying the # of USB devices running on my machine allows the USB transactions to run smoothly without the issue I indicated earlier. I'm going to add the other devices on one at a time to see where things break-down.
So it may not be a firmware/library issue as opposed to general misbehavior by something else on the bus.