Recently, I updated the unit I am running applications on with a new CODEC and amplifier; the older parts are EOL. There was a bug with the old setup. For some reason, even when a tone was not being generated, you could hear a noise emanating from the speaker when the LCD brightness was on a higher setting.
In order to counteract that problem the Amplifiers mute function (standby for old amp) was toggled on and off before and after a tone was produced:
1) Any ideas about why this might be the case? I do not believe it's the mute function on the amplifier itself because outside of the application that uses this ofstream (inside the boot loader) I can play a song and toggle it on and off with the mute function, with no delay needed.
2) Is there another way (other than ofstream) of toggling the GPIO pin 107 from within my application?
@jlb I am on an embedded system. The kernel running the program is old (2.6.35.14) and the board is a Mx5 with a Digi SoM overlay. I was under the impression that writing to the value directory was writing directly to the hardware, I will look into it but maybe you can enlighten me as to the difference between what is happening here and writing directly to the hardware.
Read the specs of the new amp. Maybe it needs some delay between functions.
It might also be that the sleep causes something that's occurring in parallel to complete. In that case you'd have to do something to synchronize the functions.
Finally, you could reduce the code in both systems: