DSP

多种方法产生波形,查表法,立即生成法

2019-07-13 21:00发布

//定义按键的值 #define RAW 11 #define SINE_FM 1 #define SINE_AM 2 #define PWM 3 #define SQUARE_WAVE_FM 4 #define SQUARE_WAVE_AM 5 int g_key_val=RAW; int g_keyIndex=0; int sin_table[512];int index_sinTable=0; //int pwm_table[256],index_pwmTable=0; int square_table[256],index_squareTable; int numTimeFreq=1; int samplePoint=512; int g_value=0; int g_analog=0; unsigned lastTime=0; int lastTime1=0; int g_pwmValue=100; int halfCycleTime=0; int totalPoints=0; int highPoints=0; int g_index_points=0; int m1=0; int m2=0; int time2_count_my=0; unsigned long currentTime=0; int key[]={RAW,SINE_FM,SINE_AM, PWM,SQUARE_WAVE_FM,SQUARE_WAVE_AM }; /* 产生正弦波表 放入m_table,表中有n个元素*/ void createSinTable(int sin_table[],int samplePoint){ for(int i=0; i