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:fe3ea8959464, committed 2015-11-17
- Comitter:
- Pumipachpro
- Date:
- Tue Nov 17 02:49:27 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 |
--- a/main.cpp Mon Aug 24 12:36:59 2015 +0000 +++ b/main.cpp Tue Nov 17 02:49:27 2015 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "MCP4922.h" +#include "math.h" MCP4922 MCP(SPI_MOSI, SPI_SCK,SPI_CS); // MOSI, SCLK, CS @@ -8,29 +9,15 @@ /**** Main Function ***/ int main(void) { - MCP.frequency(20000000); - - uint16_t i=0; - uint8_t state=0; + MCP.frequency(1000000); + double zeta = 0 ; + double PI = 3.14159265; + while(1) { - if(i < 0x0FFF) - { - i++; - + for(zeta=0 ; zeta<=360 ; zeta++) { + MCP.writeA(1000*(1+sin(zeta*(PI/180)))); + wait_us(20); } - else - { - i=0; - state = ~state; - } - - if(state ==0) - { - MCP.writeA(i); - } - else{ - MCP.writeA( ((~i)+1)&0x0FFF); - } - wait_us(20); } + } \ No newline at end of file