PaulStoffregen / USBHost_t36

USB Host Library for Teensy 3.6 and 4.0
166 stars 85 forks source link

This can sometime fail to evaluate properly #110

Open rjonkman opened 1 year ago

rjonkman commented 1 year ago

https://github.com/PaulStoffregen/USBHost_t36/blob/69b90727a5b028699b47910aa5cd6a0823de5f69/MassStorageDriver.cpp#L429

The is probably a compiler optimization issue. Sometimes StatusBlockWrapper.Tag will evalute to 0 eventhough it's been updated in the background. Surpisingly declaring StatusBlockWrapper as volatile doesn't resolve the issue. I used the following hack just before the reference line of code to force the program to reread the value of StatusBlockWrapper.Tag.

char str[50]; sprintf(str, "%d", (int)StatusBlockWrapper.Tag);