Example outputting saw-tooth waveform on DAC
Dependencies: mbed
main.cpp@0:1d3353c6dd1b, 2014-12-10 (annotated)
- Committer:
- Richard37
- Date:
- Wed Dec 10 15:15:06 2014 +0000
- Revision:
- 0:1d3353c6dd1b
Example outputting saw-tooth waveform on DAC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Richard37 | 0:1d3353c6dd1b | 1 | #include "mbed.h" |
Richard37 | 0:1d3353c6dd1b | 2 | |
Richard37 | 0:1d3353c6dd1b | 3 | |
Richard37 | 0:1d3353c6dd1b | 4 | AnalogOut my_output(PA_4); |
Richard37 | 0:1d3353c6dd1b | 5 | |
Richard37 | 0:1d3353c6dd1b | 6 | Serial pc(D8, D2); |
Richard37 | 0:1d3353c6dd1b | 7 | |
Richard37 | 0:1d3353c6dd1b | 8 | int x=0; |
Richard37 | 0:1d3353c6dd1b | 9 | |
Richard37 | 0:1d3353c6dd1b | 10 | uint16_t aout; |
Richard37 | 0:1d3353c6dd1b | 11 | |
Richard37 | 0:1d3353c6dd1b | 12 | |
Richard37 | 0:1d3353c6dd1b | 13 | int main() { |
Richard37 | 0:1d3353c6dd1b | 14 | while(1) { |
Richard37 | 0:1d3353c6dd1b | 15 | x=0; |
Richard37 | 0:1d3353c6dd1b | 16 | while( x<4096) |
Richard37 | 0:1d3353c6dd1b | 17 | { |
Richard37 | 0:1d3353c6dd1b | 18 | my_output.write_u16(x); |
Richard37 | 0:1d3353c6dd1b | 19 | x=x+1; |
Richard37 | 0:1d3353c6dd1b | 20 | wait_us(50); |
Richard37 | 0:1d3353c6dd1b | 21 | } |
Richard37 | 0:1d3353c6dd1b | 22 | |
Richard37 | 0:1d3353c6dd1b | 23 | |
Richard37 | 0:1d3353c6dd1b | 24 | //pc.printf("%d\n\r", x); |
Richard37 | 0:1d3353c6dd1b | 25 | |
Richard37 | 0:1d3353c6dd1b | 26 | } |
Richard37 | 0:1d3353c6dd1b | 27 | } |