v
Dependencies: mbed
Fork of MCP4922_Sinewave by
Diff: main.cpp
- Revision:
- 3:0ff7b96f04b8
- Parent:
- 2:2244c8986987
--- a/main.cpp Mon Aug 24 12:36:59 2015 +0000 +++ b/main.cpp Mon Nov 02 08:21:02 2015 +0000 @@ -8,29 +8,23 @@ /**** Main Function ***/ int main(void) { - MCP.frequency(20000000); + MCP.frequency(10000000); - uint16_t i=0; - uint8_t state=0; + double i= 0; + while(1) { - if(i < 0x0FFF) + if(i < 3.14*2) { - i++; + i+=0.001; } else { i=0; - state = ~state; } - if(state ==0) - { - MCP.writeA(i); - } - else{ - MCP.writeA( ((~i)+1)&0x0FFF); - } + MCP.writeA(((sin(i)+1)/2.0*4095)); + wait_us(20); } } \ No newline at end of file