Hi,
I would like to generate pulse position modulation signal by C6748 LCDK, i.e, the mapping is '0' -> '10' while '1' -> '01'.
The code is as follows, which is modified from the sine wave generation code in the book 'Digital signal processing and applications with the OMAP-L138 eXperimenter'.
*************************************************************
#include "L138_LCDK_aic3106_init.h"
#define LOOPLENGTH 8
#define BUFLENGTH 256
#define DATALENGTH 2
int16_t PPM_table_0[LOOPLENGTH] = {10000, 10000, 10000, 10000, 0, 0, 0, 0}; // for mapping '0' -> '10'
int16_t PPM_table_1[LOOPLENGTH] = {0, 0, 0, 0, 10000, 10000, 10000, 10000}; // for mapping '1' -> '01'
int16_t DATA_table[DATALENGTH] = {0, 1}; // data
int16_t PPM_ptr_0 = 0; // pointer into lookup PPM table 0
int16_t PPM_ptr_1 = 0; // pointer into lookup PPM table 1
int16_t DATA_ptr = 0; // pointer into lookup Data table
int32_t buffer[BUFLENGTH];
int16_t buf_ptr = 0;
interrupt void interrupt4(void) // interrupt service routine
{
if (DATA_table[DATA_ptr] == 0) // mapping of '0'
{
int ii;
for (ii = 0; ii <= LOOPLENGTH; ii++) {
int16_t sample;
sample = PPM_table_0[PPM_ptr_0]; // read sample from table
output_left_sample(sample); // output sample
PPM_ptr_0 = (PPM_ptr_0+1)%LOOPLENGTH; // increment table index
buffer[buf_ptr] = (int32_t)(sample); // store sample in buffer
buf_ptr = (buf_ptr+1)%BUFLENGTH; // increment buffer index
}
}
else // mapping of '1'
{
int ii;
for (ii = 0; ii <= LOOPLENGTH; ii++) {
int16_t sample;
sample = PPM_table_1[PPM_ptr_1]; // read sample from table
output_left_sample(sample); // output sample
PPM_ptr_1 = (PPM_ptr_1+1)%LOOPLENGTH; // increment table index
buffer[buf_ptr] = (int32_t)(sample); // store sample in buffer
buf_ptr = (buf_ptr+1)%BUFLENGTH; // increment buffer index
}
}
DATA_ptr = (DATA_ptr+1)%DATALENGTH; // increment table index
return;
}
int main(void) {
L138_initialise_intr(FS_48000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_LINE_INPUT);
while(1);
}
*********************************************
The expected result should be the loop of '10000, 10000, 10000, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 10000, 10000, 10000'.
However, the result is not correct.
Thanks in advance!
PP