Skip to main content
11 events
when toggle format what by license comment
Sep 11, 2023 at 15:05 answer added emha1969 timeline score: 0
Dec 9, 2019 at 17:00 vote accept kbrown323
Dec 9, 2019 at 17:00 answer added kbrown323 timeline score: 3
Dec 4, 2019 at 18:04 answer added Chris Stratton timeline score: 5
Dec 4, 2019 at 17:25 comment added kbrown323 Just to be clear, I am aware that it's generally bad practice to do "too much" in an interrupt and you want to keep interrupt logic simple to prevent disruption of main program flow. Flash programming certainly qualifies. But at this point, there is literally nothing else executing (empty while loop), and when in actual use for USB Mass Storage the device will be in a download firmware mode where normal execution is stopped.
Dec 4, 2019 at 17:18 comment added kbrown323 Just to be certain, it's not a clock error since I got the entire USB communication working perfectly when writing to RAM. @rom1nux I do indeed erase it afterwards in that example, but the actual code dealing with the USB data blocks and all did not, and I'm stepping through it with the debugger and watching the memory address change (or not, in the problematic one). Taking out this extra erase doesn't cause a difference in behavior.
Dec 4, 2019 at 17:14 comment added kbrown323 @ChrisStratton The path it takes to the call is through a few layers of STM libraries to reach each function. I believe it has something to do with where it's being called from, considering it works in one function but not another. Flash is writing fine in main() and wherever else I try, it's just in this USB write function that it fails. Edit: Sorry hitting enter submitted the comment. Why can this not be done in an interrupt context? Both functions I've demonstrated are called in a USB interrupt managed by STM's libraries. I have no control over when this gets called.
Dec 3, 2019 at 0:18 comment added rom1nux You erase the page (FLASH_PageErase) after programming (HAL_FLASH_Program)... If it's "code extraction" mistake, take look of your flash latency and prefetch and co.
Dec 2, 2019 at 23:18 comment added Chris Stratton What is the path by which execution reaches each point? Try putting the function in its own file, and calling it both early in main() and also at whatever point you are dealing with the actual data. Hopefully it goes without saying that you can't do this in an interrupt context. Make sure your flash timing is appropriate to whatever system clock you need for USB...
Dec 2, 2019 at 22:50 review First posts
Dec 3, 2019 at 0:25
Dec 2, 2019 at 22:45 history asked kbrown323 CC BY-SA 4.0