Associate III
June 23, 2016
Question
STM32F3 processes an invalid USB Setup Packet in PCD_EP_ISR_Handler with ep->xfer_count very large
- June 23, 2016
- 5 replies
- 4118 views
Posted on June 23, 2016 at 18:01
Hi all,
I have a STM32F302CBT6, and have created a USB Audio Device (speaker) project for it using STM32CubeF3 version 1.5.Basically, the project initially works. If I for example, set the STM32 as the default audio device and then click the Windows volume control it plays that sound to the STM32, and data are received in the USBD_AUDIO_DataOut etc.However, this only works the first time. The program ends up in the Hard Fault handler. The call stack shows:&sharp0 ?? HardFault_Handler () (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\src\stm32f3xx_it.c:75)&sharp2 0x801335c USBD_ParseSetupRequest(req=0x208, pdata=0x20004f20 <hpcd_USB_FS+884> ''C'') (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\usb\usbd_ctlreq.c:701)&sharp3 0x8012804 USBD_LL_SetupStage(pdev=0x0, psetup=0x20004f20 <hpcd_USB_FS+884> ''C'') (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\usb\usbd_core.c:266)&sharp4 0x8011a3c HAL_PCD_SetupStageCallback(hpcd=0x20004bac <hpcd_USB_FS>) (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\src\usbd_conf.c:130)&sharp5 0x800a5ea PCD_EP_ISR_Handler(hpcd=0x20004bac <hpcd_USB_FS>) (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\hal\stm32f3xx_hal_pcd.c:401)&sharp6 0x800ab26 HAL_PCD_IRQHandler(hpcd=0x20004bac <hpcd_USB_FS>) (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\hal\stm32f3xx_hal_pcd.c:566)&sharp7 0x801182a USB_LP_IRQHandler() (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\src\stm32f3xx_it.c:254)&sharp9 ?? main () (C:\SoftwareProject\Arm\STM32F3\STM32F302_USB_Speaker\src\main.c:109)At &sharp3 you can see there is a problem: pdev should not be 0x0. Somehow it changed. Note that it must have had a valid value for all of the previous setup requests to work, and for the first audio data out to work.Any Ideas? This problem occurs with the minimal code straigh out of STM32Cube, which I will try to attach. EDIT: Project code is attached. Its a minimal project that exhibits this problem, straight out of STM32Cube. I think the only things I changed in STM32Cube was the audio sampling frequency from 22100 to 48000 Hz.Just as a caveat: If I set a breakpoint at USBD_ParseSetupRequest (anywhere in that function) pdev is not modified and the program continues to run correctly #stm32f3 #hardfault #bug #usb