Advertisement
kirill_76rus

DDS_final

Jun 10th, 2021
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include<c6x.h>
  2. #include<stdint.h>
  3. /********************************************/
  4. /*Block of vatiables*/
  5. uint16_t sin[] = { 0, 1559, 3114, 4663, 6201, 7725, 9231, 10717, 12178, 13611,
  6. 15014, 16383, 17715, 19006, 20255, 21457, 22611, 23714, 24763, 25756,
  7. 26691, 27565, 28377, 29124, 29805, 30419, 30964, 31439, 31843, 32174,
  8. 32433, 32618, 32729 };/*This array for 1 quadrant of phase*/
  9. int16_t output[0xFFU];/*This is a result of working DDS*/
  10. uint16_t phase[0xFFU];/*It is a phase accumulator*/
  11. uint16_t norming_coefficient = 1000;
  12. /**********************************************/
  13. int main() {
  14. uint8_t index = 0;
  15. for(index = 0; index < 0xFF; ++index){
  16. uint16_t current_phase = (norming_coefficient*index)%32768;
  17. if(current_phase <= 8192){
  18. output[index] = sin[(current_phase%8193)/256];
  19. }
  20. else if(current_phase > 8192 && current_phase <= 16384){
  21. output[index] = sin[32 - (current_phase%8193)/256];
  22. }
  23. else if(current_phase > 16384 && current_phase <= 24576){
  24. output[index] = -sin[(current_phase%8193)/256];
  25. }
  26. else if(current_phase > 24576 && current_phase <= 32768){
  27. output[index] = -sin[32 - (current_phase%8193)/256];
  28. }
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement