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 4:1a2a74472be9, committed 2015-11-05
- Comitter:
- aimp
- Date:
- Thu Nov 05 08:02:26 2015 +0000
- Parent:
- 3:863a9b7d417a
- Commit message:
- lab
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Nov 05 07:29:03 2015 +0000
+++ b/main.cpp Thu Nov 05 08:02:26 2015 +0000
@@ -1,4 +1,3 @@
-
#include "mbed.h"
#include "MCP4922.h"
@@ -8,18 +7,29 @@
/**** Main Function ***/
int main(void)
{
- MCP.frequency(1000000);
- int i;
- float a,y;
+ MCP.frequency(20000000);
+
+ uint16_t i=0;
+ uint8_t state=0;
while(1) {
-
-
- for(a=1;a<=360;a++)
- {
- y= sin(a*(6.28/360));
- MCP.writeA((y+1)*2000);
- }
-
-
+ if(i < 0x0FFF)
+ {
+ i++;
+
+ }
+ 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
