Roberto Vázquez
/
frdm_gpio_DAC
convertidor digital. analogico
Revision 0:02e65197aa23, committed 2015-06-24
- Comitter:
- rvazquezc
- Date:
- Wed Jun 24 00:14:15 2015 +0000
- Commit message:
- convertidor-Digital-analogico
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jun 24 00:14:15 2015 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" + +// The sinewave is created on this pin +AnalogOut aout(DAC0_OUT); + +int main() +{ + const double pi = 3.141592653589793238462; + const double amplitude = 0.5f; + const double offset = 65535/2; + double rads = 0.0; + uint16_t sample = 0; + + while(1) { + // sinewave output + for (int i = 0; i < 360; i++) { + rads = (pi * i) / 180.0f; + sample = (uint16_t)(amplitude * (offset * (cos(rads + pi))) + offset); + aout.write_u16(sample); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jun 24 00:14:15 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa \ No newline at end of file