Tool/software: Code Composer Studio
Dear TI Hello,
I am using the Signal Generator library for C28x DSP,
I couldn't find a clean sinus wave using the SGENT_1 (look up table).
My interrupt is triggered every 50us (20Khz) as in the sgen_mdl pdf file.
C code:
typedef struct { unsigned int freq; unsigned int step_max; unsigned int alpha; int gain; int offset; int out; void (*calc)(void *); }SGENT_1; #define SGENT_1_DEFAULTS { 5369,\ 1000,\ 0,\ 0x7fff,\ 0,\ 0,\ (void (*)(void *))SGENT_1_calc} SGENT_1 sgen = SGENT_1_DEFAULTS; int32 t_i32SinusBuf[SINUS_BUF_LEN]; interrupt void Timer0_ISR(void) { volatile static int32 s_i32Sinus; static int32 *s_pi32SinusBufPtr = t_i32SinusBuf; /* Acknowledge this interrupt to receive more interrupts from group 1 */ PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; /* Clear Timer interrupt flag */ CpuTimer0Regs.TCR.bit.TIF = 0; /* Increment the timer0 interrupt counter */ CpuTimer0.InterruptCount++; /* Update sgen macro */ sgen.calc(&sgen); s_i32Sinus = sgen.out; /* Write sins to buffer */ *s_pi32SinusBufPtr++ = s_i32Sinus; if( s_pi32SinusBufPtr == (t_i32SinusBuf + SINUS_BUF_LEN)) { s_pi32SinusBufPtr = t_i32SinusBuf; } }
I am using a 50 int32 buffer to display out using Single time scope.
Thank you in advance,
S.Tarik,