Question
Hard Fault using STM32F0x2_USB-FS-Device_Lib V1.0.0 on STM32F072CB
Posted on June 15, 2015 at 13:27
Hello,
I'm working with the USB Library on a STM32F072CB.The project I use is the virtual com port example inclueded in the library.If I run the example without changing anything it works fine. Because the project isn't exactly what I need I have to change it a little bit. Therefor I changed the optimization level from 3 to 0, so I'm able to see all local variables in watch windows and so on.Apperently this results in getting an hard fault over and over again.All happens in the ''PMAToUserBufferCopy'' function in usb_core.cExactly the instruction: *(uint16_t*)pbUsrBuf++ = *pdwVal++; in the for loop of this function. /** * @brief Copy a buffer from user memory area to packet memory area (PMA) * @param pbUsrBuf = pointer to user memory area. * @param wPMABufAddr: address into PMA. * @param wNBytes: no. of bytes to be copied. * @retval None */void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes){ uint32_t n = (wNBytes + 1) >> 1; uint32_t i; uint16_t *pdwVal; pdwVal = (uint16_t *)(wPMABufAddr + PMAAddr); for (i = n; i != 0; i--) { *(uint16_t*)pbUsrBuf++ = *pdwVal++; pbUsrBuf++; }}I have no idea why this happens with optimization level 0 but not with level 3.Does anyone has/had this issue?It would be great if someone could help me out.Blubimo #stm32f0-usb-hard-fault