ATSAMD21E18A USB Mass Storage Host Different Behavior When Optimized

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I have an app that is using an ATSAMD21E18A to write to a USB drive. The app works as intended when optimization is off. When I turn optimization on to any level the app gets stuck calling mschf_is_busy from within msc_diskio_select when I plug the USB drive in.

 

Does anyone have any ideas as to why this would be?

 

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I figured this one out. The function mschf_is_busy looks at the is_busy member of it's pointer argument. The pointer is not declared as volatile in msc_diskio_select, but the is_busy flag sometimes gets cleared by an interrupt. With optimizations on the is_busy flag gets put in a register and is therefore not updated by the isr. Peppering "volatile"s through the code in question seemed to do the trick.