cancel
Showing results for 
Search instead for 
Did you mean: 

Troubleshooting required with STM32f4 USB Microphone device

contact2
Associate II
Posted on November 15, 2013 at 14:41

Dear all,

I think I am almost done with the this program, but when I plug after pprogramming my STM32F4 Discovery board. It gives an exclamation mark, (Code 10) generally. ''The I/O request was canceled.'' is written as well in the device status. I am attaching the programming made on KEIL uVision please help me out with this program.

Umair Mukati.

#usb #microphone #stm32f4discovery
16 REPLIES 16
tsuneo
Senior
Posted on November 22, 2013 at 01:37

As you have working setup of your application, it doesn't take any more than 10 minutes to take sniffer log, including the download time of the trial sniffer. If your firmware could get pass Get_Descriptor( Config ), USBTrace will check the config descriptor sets.

If you could't interpret the sniffer log well, post the log.

I'm not sure why you would hesitate such a trivial job.

Don't miss the chance to learn the way, how to debug USB application 😉

Tsuneo

contact2
Associate II
Posted on November 22, 2013 at 17:07

Dear Tsuneo,

You are right, atlast I came to a single line issue, which needs to be resolved.

The problem is occurred when host asks for string descriptor, its request get cancelled.

And also on STM32F4 board LED which is toggling in main loop stops toggling.

0690X00000604llQAA.png

contact2
Associate II
Posted on November 22, 2013 at 18:13

It is going into an infinite loop of hardfault interrupt.

tsuneo
Senior
Posted on November 22, 2013 at 18:35

Err..

Is it the first error after device plug-in? I believe you'll see the first error at ''SelectInterface'' (Set_Interface) URB, just after ''SelectConfiguration'' URB (Set_Configuration). After the first error, recovery sequence follows. Then, you should find the first error on the log. I thought I'll trace the bug step by step with you. But I'm busy this weekend, I can't access to this forum for a while. And then, I've quickly analyzed the bug on my side. I ran your code on my F4-Discorery board, with a hardware bus analyzer. It fails at Set_Interface just after Set_Configuration. On the debugger, your code drops into HardFault, in USBD_IsoINIncomplete() (usbd_core.c) The direct reason of HardFault is, on your code, IsoINIncomplete member of AUDIO_cb is NULL This member (function pointer) is called at USBD_IsoINIncomplete. Call to NULL pointer caused the HardFault. To fix this bug, fill this member with a routine, like usbd_audio_OUT_Incplt()

usbd_audio_core.c
static uint8_t usbd_audio_IN_Incplt (void *pdev);
USBD_Class_cb_TypeDef AUDIO_cb =
{
usbd_audio_Init,
usbd_audio_DeInit,
usbd_audio_Setup,
NULL, /* EP0_TxSent */
usbd_audio_EP0_RxReady,
usbd_audio_DataIn,
usbd_audio_DataOut,
usbd_audio_SOF,
NULL, // <---------- usbd_audio_IN_Incplt
usbd_audio_OUT_Incplt, 
USBD_audio_GetCfgDesc,
#ifdef USB_OTG_HS_CORE 
USBD_audio_GetCfgDesc, /* use same config as per FS */
#endif 
};
static uint8_t usbd_audio_IN_Incplt (void *pdev)
{
return USBD_OK;
}

The indirect reason is, you are calling DCD_EP_Tx() at usbd_audio_Init() (usbd_audio_core.c), which is called at Set_Configuration process. Delete this call. DCD_EP_Tx() expects isoc transaction from host. As no isoc transaction comes, IsoINIncomplete interrupt occurs. Your firmware should call DCD_EP_Tx() just after you got microphone sampling data in a array, to send this array data to host. Maybe you've replaced DCD_EP_PrepareRx() of the original usbd_audio_Init() into DCD_EP_Tx(). But there is asymmetry between Rx and Tx. DCD_EP_PrepareRx() is called before host sends packet, DCD_EP_Tx() is called just when device sends packet. I'm sorry, I can't enjoy the debug process with you. Tsuneo
contact2
Associate II
Posted on November 23, 2013 at 05:19

Thank you very much Tsuneo,

Now no more HardFaults and exclamation mark.

apbqdo
Associate II
Posted on February 28, 2014 at 10:11

Umair, could you be so kind to attach any workable version? Or it is a secret? Your topic is very helpful anyway, but I think that I will spend a few days to reconstruct your steps.

Denis.

apbqdo
Associate II
Posted on April 01, 2014 at 00:44

Gurus, I have added the changes that Tsuneo explained:

1. Added usbd_audio_IN_Incplt function.

2. Removed DCD_EP_Tx() call from usbd_audio_Init().

USB device is found in the system, but no sound. Recording process starts, but 0 seconds length of file. Probably any ideas? I do not feel enough experience to solve such complex problem.

________________

Attachments :

usb_mic.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0cb&d=%2Fa%2F0X0000000bbL%2F7JkuyxuwUeSatQyO6fh6a0nW.hVl6WKZnROB4ehc5Mo&asPdf=false