2024-12-16 06:10 AM - last edited on 2024-12-19 02:45 AM by SofLit
Moved from MPUs forum as STM32F4 is an MCU.
Hello,
Im trying to write the USB code from scratch.
I have written the code that enables and initializes the usb OTG and I can confirm that it receives SETUP packets in the RX FIFO.
I am receiving the GET_DESCRIPTOR request and i am trying to respond to it but I am unable to write in the TX FIFO in order to respond to the packages.
I have followed and executed the steps in page 1368 ( IN data transfers , packet write). When i try to write to the FIFO using the memcyp command i am unable to confirm that the packet is indeed written in my FIFO and there is no change in the USB behavior ( appears as :Device Descriptor Request Failed in device manager after 10-30 seconds).
If i try to manually write the FIFO in 32 or 64 bits at a time, it doesn't work at all and i get to the Hard Fault Handler.
The addresses i have tried to write packages to are 0x50001000 , 0x50002000 and 50001040 , nothing worked .
Solved! Go to Solution.
2024-12-19 01:53 AM
I was getting to the HardFault_Handler () due to a pointer misuse .
2024-12-16 07:59 AM
> If i try to manually write the FIFO in 32 or 64 bits at a time, it doesn't work at all and i get to the Hard Fault Handler.
Have you tried in 16 bits?
2024-12-16 09:16 AM
You may check my USB code - link below. You need to read/write FIFO write data in 32-bit units, so no memcpy.
2024-12-17 12:12 AM
Just tried it , does NOT work , with 16 bits even then OUT packet cant be read.
2024-12-17 12:15 AM
I tried not using memcpy and accessing the FIFO only in 32 bits but i get to the HardFault_Handler after trying to write to the FIFO. FYI for some reason reading the FIFO with memcpy ( , ,4) works fine. I tried reading it without memcpy in case it crashed the FIFO but the behavior remained the same. Thanks for the GitHub link.
2024-12-17 06:08 AM
I tried using your code from GitHub but I am having difficulties with a specific error, I already have opened an issue if you can check it out.
2024-12-19 01:53 AM
I was getting to the HardFault_Handler () due to a pointer misuse .