Hello,
I am working on Signal Processing using DSK6713. Our task is take analog data process it and send to output. For this we had chosen to take analog data from MCBSP (line-in) and after processing send to MCBSP (line-out). For this task I had studied TI Wiki Pages and Book of Ralph Chasing. At last I had written this code.
#include <stdio.h>
#include <c6x.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
#include <dsk6713.h>
#include <dsk6713_aic23.h>
/* Intializing Audio Codec */
DSK6713_AIC23_CodecHandle hCodec;
/* Configuring Audio Codec */
DSK6713_AIC23_Config config = {
0x0017, /* 0 - DSK6713_AIC23_LEFTINVOL Left line input channel volume */
0x0017, /* 1 - DSK6713_AIC23_RIGHTINVOL Right line input channel volume */
0x01f9, /* 2 - DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */
0x01f9, /* 3 - DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */
0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */
0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */
0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */
0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */
};
interrupt void serialPortRcvISR(void);
void hook_int();
int volumeGain;
void main(){
DSK6713_init(); // Initialize the board support library
DSK6713_LED_init();
/* Open Audio Codec */
hCodec = DSK6713_AIC23_openCodec(0, &config);
/* Set Sampling Freq of Audio Codec */
DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_96KHZ);
volumeGain = 100; /* Volume Gain of audio signal */
hook_int(); /* Interrupt Function */
DSK6713_LED_on(1);
while(1){
}
}
void hook_int(){
IRQ_globalDisable(); // Globally disables interrupts
IRQ_nmiEnable(); // Enables the NMI interrupt
IRQ_map(IRQ_EVT_RINT2,15); // Maps an event to a physical interrupt
IRQ_enable(IRQ_EVT_RINT2); // Enables the event
IRQ_globalEnable(); // Globally enables interrupts
}
interrupt void serialPortRcvISR(){
Uint32 temp;
DSK6713_LED_on(1);
/* Reading Data from MCBSP */
temp = MCBSP_read(DSK6713_AIC23_DATAHANDLE);
temp = temp * volumeGain;
/* Signal Processing Algo will be here */
/* Writing Data to MCNSP */
MCBSP_write(DSK6713_AIC23_DATAHANDLE, temp);
}
Above code work as:
- After initialization hook_int(); function is called in which
- Map MCBSP event to interrupt # 15.
- Enable the event.
- Then it will go into infinite while loop until there is data on line-in
- As data will arrive at line-in it will interrupt DSK.
- For testing I had set led on to check the working of code
- Input is given through PC's line-out port.