HW5 - ndm736/ME433_2023 GitHub Wiki
Old using an SPI DAC video 2020 (This is 2020's video that uses the 12-bit version of the DAC chip)
Use the SPI sample code and datasheet for the MCP4912 (note this is the 10 bit version) 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 HW5 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:
- Be careful inserting the chip into your breadboard. Press each side of your chip against a table to bend the pins more perpendicular to the body of the chip so that it fits easier into the breadboard.
- Set the baud of the SPI to something really slow, like 12kHz, so you can see the CS, SCK, and SDO values on nScope (on a real oscilloscope you can go full speed). 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-1023) 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.