Forum Discussion
Altera_Forum
Honored Contributor
8 years agoCreating square waves of varying frequencies
Hi all, I'm currently trying to produce sound via an Audio Controller by creating square waves that change in frequency depending on which switch on the FPGA is flipped. I'm able to get sound, ...
Altera_Forum
Honored Contributor
8 years agoI suspect you have a subtle typo somewhere. However, it's not evident in the code you've posted.
A more general observation - a counter per note is fine. However, you're controlling and selecting each counter based on your switched. May I suggest running the note counters continuously, each with their own 'dac_out' signal, and selecting which one you wish to pipe to the DAC. This will simplify your code greatly. Simpler code leaves less room for error. Alternatively, a single counter, and single 'dac_out' signal, but with selectable wrap points based on note selection. Either way, I'm sure the simpler code that would result, from either method, will help. Cheers, Alex