Advertisement
Guest User

mbed gla lab2

a guest
Mar 5th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include "mbed.h"
  2.  
  3. DigitalOut gpo(PTD7);
  4. Serial async_port(PTA2, PTA1);
  5. char x, count;
  6.  
  7. int main(){
  8. const int iterations = 2000;
  9. // double sinValues[iterations];
  10. // for(int i = 0; i < iterations; i++) {
  11. // sinValues[i] = 16*2047.0*(1+sin(2*3.142*(i/50.0)));
  12. // }
  13.  
  14. async_port.baud(9600);
  15.  
  16. int j;
  17. char higher, lower;
  18.  
  19. while(1){
  20. for(int i = 0; i < iterations; i++) {
  21. j = 16*2047.0*(1+sin(2*3.142*(i/50.0)));//sinValues[i];
  22. higher = (j & 0xFF00) >> 8;
  23. lower = j & 0x00FF;
  24.  
  25. async_port.putc(higher);
  26. async_port.putc(lower);
  27. gpo = i & 1;
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement