labSPI
Dependencies: mbed
Fork of MCP4922_Sinewave by
Diff: main.cpp
- Revision:
- 3:863a9b7d417a
- Parent:
- 2:2244c8986987
- Child:
- 4:1a2a74472be9
diff -r 2244c8986987 -r 863a9b7d417a main.cpp --- a/main.cpp Mon Aug 24 12:36:59 2015 +0000 +++ b/main.cpp Thu Nov 05 07:29:03 2015 +0000 @@ -8,29 +8,18 @@ /**** Main Function ***/ int main(void) { - MCP.frequency(20000000); - - uint16_t i=0; - uint8_t state=0; + MCP.frequency(1000000); + int i; + float a,y; while(1) { - if(i < 0x0FFF) - { - i++; - - } - else - { - i=0; - state = ~state; - } - - if(state ==0) - { - MCP.writeA(i); - } - else{ - MCP.writeA( ((~i)+1)&0x0FFF); - } - wait_us(20); + + + for(a=1;a<=360;a++) + { + y= sin(a*(6.28/360)); + MCP.writeA((y+1)*2000); + } + + } } \ No newline at end of file