They offer this device as an i2c demo. I do what they say, as follows:
cd examples cp i2c-mcp4725-dac.cpp ../main.cpp cd .. make clean makeIt builds lickety split without errors or warnings. I made some mods. First of all, it is set up to wait for a button press from some board button. We don't have that on a blue pill, so I comment that out.
Also I am getting tired of redefining the BOARD_LED_PIN, so I edited the file wirish/boards/maple_mini/include/board/board.h and changed the value from 33 to 14
For whatever reason this example just would not run, or didn't seem to. So I grabbed my working blink demo and begin adding code bit by bit, and ultimately it just worked! Who knows what the issue was. I should go back to the original demo perhaps and sort things out.
What I did do is to connect up a serial console to Serial1 and change all the USBserial calls to Serial1 calls. Between that change and getting the LED pin set properly things just worked.
It is important to note that the Serial1 pins are A9 and A10 for the blue pill used as a maple-mini, NOT pins B6 and B7 as I was expecting.
Very mysterious. Worrisome even. It should work and I would like to understand what is wrong, because I expect it to bite me in the future with other projects.
I comment out virtually everything, leaving only the setup() function with a call to Serial1.begin(115200) followed by a greeting message. This works.
Now it is a tedious process of trial and error, uncommenting first one section, then another. The smart way would be a binary search, but we aren't that smart.
The entire setup() routine works, with serial messages and a write to and read from the DAC. I go for broke and now it work -- I get all the messages and the sawtooth wave. This makes no sense at all.
And now I try something even more minimal. I copy the example, comment out only the two lines that deal with waiting for the button -- and it works! I have a sawtooth on the scope. This is all insane and unpredictable.
I'll leave the chip powered down while I eat dinner and see what happens after that. And after that, it fired right up as soon as I applied power.
Tom's Computer Info / tom@mmto.org