HW2 - ndm736/ME433_2020 GitHub Wiki

Use the SPI sample code and datasheet for the MCP4922 to generate a 2Hz sine wave and a 1Hz triangle wave. Both should range from 0V to 3.3V. The update rate of the DAC should be at least 50 times faster than the frequency of the signal you are producing.

Make a folder called HW2 in your repo and upload your code, as well as a screenshot of the output voltages, showing at least 3 cycles of each signal (include the Horizontal Control value in the screenshot so I can verify the frequency).

Suggestions:

  • You probably need to move the MCP4922 chip out of one breadboard and into another. Be careful removing it, try not to pull it out by only one side, the pins will bend. I like to wedge the tip of a multimeter under one end, move it up about a mm, then do the other side, and go back and forth until the chip is out.
  • Set the baud of the SPI to something really slow, like 12kHz, so you can see the CS, SCK, and SDO values on nScope. It is helpful for debugging. Once it is working, you can max out the baud. The nScope has a bandwidth of about 100kHz, so it can't see signals faster than 100kHz.
  • Test one thing at a time! Don't write the entire assignment and assume it will work, break it up into smaller parts and test as you go: Write a function that takes the channel and the voltage (as an unsigned short, 0-4096) as inputs. At first, just hard code the entire 16 bits to send to the DAC, with something like 1.65V as the output, to test your SPI writes. Then actually use the channel and voltage.