gen triangle wave
Dependencies: mbed
Fork of MCP4922_Sinewave by
Revision 5:c4a38038ab44, committed 2015-12-23
- Comitter:
- soulx
- Date:
- Wed Dec 23 12:19:03 2015 +0000
- Parent:
- 2:2244c8986987
- Commit message:
- -
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2244c8986987 -r c4a38038ab44 main.cpp --- a/main.cpp Mon Aug 24 12:36:59 2015 +0000 +++ b/main.cpp Wed Dec 23 12:19:03 2015 +0000 @@ -13,24 +13,19 @@ uint16_t i=0; uint8_t state=0; while(1) { - if(i < 0x0FFF) - { + if(i < 0x0FFE) { i++; - - } - else - { + + } else { i=0; state = ~state; } - - if(state ==0) - { + + if(state ==0) { MCP.writeA(i); - } - else{ - MCP.writeA( ((~i)+1)&0x0FFF); - } - wait_us(20); + } else { + MCP.writeA( ((~i)+1)&0x0FFF); + } + wait_us(1); } } \ No newline at end of file