Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of MCP4922_Sinewave by
Revision 3:0ff7b96f04b8, committed 2015-11-02
- Comitter:
- Peeraya
- Date:
- Mon Nov 02 08:21:02 2015 +0000
- Parent:
- 2:2244c8986987
- Commit message:
- FINISH
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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