Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<c6x.h>
- #include<stdint.h>
- /********************************************/
- /*Block of vatiables*/
- uint16_t sin[] = { 0, 1559, 3114, 4663, 6201, 7725, 9231, 10717, 12178, 13611,
- 15014, 16383, 17715, 19006, 20255, 21457, 22611, 23714, 24763, 25756,
- 26691, 27565, 28377, 29124, 29805, 30419, 30964, 31439, 31843, 32174,
- 32433, 32618, 32729 };/*This array for 1 quadrant of phase*/
- int16_t output[0xFFU];/*This is a result of working DDS*/
- uint16_t phase[0xFFU];/*It is a phase accumulator*/
- uint16_t norming_coefficient = 1000;
- /**********************************************/
- int main() {
- uint8_t index = 0;
- for(index = 0; index < 0xFF; ++index){
- uint16_t current_phase = (norming_coefficient*index)%32768;
- if(current_phase <= 8192){
- output[index] = sin[(current_phase%8193)/256];
- }
- else if(current_phase > 8192 && current_phase <= 16384){
- output[index] = sin[32 - (current_phase%8193)/256];
- }
- else if(current_phase > 16384 && current_phase <= 24576){
- output[index] = -sin[(current_phase%8193)/256];
- }
- else if(current_phase > 24576 && current_phase <= 32768){
- output[index] = -sin[32 - (current_phase%8193)/256];
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement