
First Shot at Sin wav from DAC
Fork of MCP4822_demo by
main.cpp
- Committer:
- bjeffway
- Date:
- 2016-04-01
- Revision:
- 2:e8d2b1992e9f
- Parent:
- 1:77d25d0f67d6
File content as of revision 2:e8d2b1992e9f:
// 2.9Khz #include "mbed.h" #include "MCP4822A.h" PinName cspins[] = {(D9)}; MCP4822A MCP(1, D11, D13, cspins, D10); // NDACs, MOSI, SCLK, nCS-list, nLdac int main() { int i; // printf("\r\n\r\nSetting SPI clock frequency to 10 MHz.\r\n"); // MCP.frequency(10000000); printf("\r\n\r\nSetting SPI clock frequency to 20 MHz.\r\n"); MCP.frequency(20000000); // Begin by setting all the DACs to 1000 millivolts at gain 2. printf("Loading all channels with 1000mV at gain 2...\r\n"); MCP.latch_disable(); MCP.writeA2(0, 2520); MCP.writeB2(0, 2520); wait(4); printf("Latching now.\n"); MCP.latch_enable(); wait(4); while (1) { for (float i = 0; i < 6.28; i=i+.1) { MCP.writeA2(0, 1500+sin(i)*1500); } } }