Cannot GET DAC to play sine wave on speaker on Core2



  • Using UIFlow, I don't get the DAC to produce an audible sine wave on the internal speaker. What am I doing wrong? The speaker is not broken, it can play a wav file.

    1. Initialization
    2. I play a wav file from internal flash to confirm that the speaker is working.
    3. I initialize the Dac 0 to port 25. This should be connected to the speaker
    4. I start a sine wave on the DAC with a duration of 0, that should be infinite.
    5. A loop with some code to read and display the ToF sensor.
    6. The code to modify the frequency is omitted. I just want it to play 440 Hz for to sort out this problem. The loop code displays the sensor output changes, no problem there.

    I want to make a Theremin using 2 ToF sensors, the DAC and the internal speaker. PbHub is not working either but there is a bug report elsewhere for that.
    I also noticed I cannot set the speaker volume for the WAV? How to do that?
    Is that the problem?
    See screenshot below:

    0_1612985419639_Dac_not_outputting_sound2.png



  • Hello @nicenemo

    looking at the M5Core2 schematic I can see that the two GPIOs selectable in the Init dac0 in pin xx, GPIO25 and GPIO26, are only connected to the MBus but not to the internal speaker of the M5Core2. In contrast GPIO25 is connected to the internal speaker of M5Stack (Gray, Fire etc.). I have a feeling that the DAC blocks are only useable with the internal speaker in M5Stack but not with the one inside M5Core2.

    Thanks
    Felix



  • @felmue Thanks! So then I can add an external speaker or stick a wire on it and use that as the antenna of an AM transmitter ;)
    like in this video: https://www.youtube.com/watch?v=lRXHd3HNzEo