|
|
View previous topic :: View next topic |
Author |
Message |
KeithA
Joined: 09 Mar 2009 Posts: 4
|
Help with TLV320AIC23B codec, dsPIC development board |
Posted: Tue Mar 10, 2009 6:11 pm |
|
|
Hello everyone,
I just recently purchased the Analog dsPic development board "dsPIC33FJ128GP706" in order to get more familiar with them. I've been trying the exercises shown in the book in the effort to test out the board but I've had a few non-working exercises. This one in particular is suppose to generate a tone internally and output it to the TLV320AIC23B codec. I typed in the code example word-for-word as shown in the book and all I get when connecting a set of headphones to any of the outputs is white noise. Here's the code for this particular exercise:
Code: |
#include <33fj128gp706.h>
#fuses HS, NOWDT, NOCOE, NODEBUG, PR
#use delay(clock=12000000)
#use rs232(baud=9600, UART2)
#include <math.h>
//#include <flex_lcd.c>
#include <TLV320AIC23B.c>
//#define LCD_DATA_PORT
#define PCM_TABLE_SIZE 256
#define MAXIMUM_VAL 32768
unsigned int8 pcm_pos;
signed int16 pcm_table[PCM_TABLE_SIZE];
const float INCREMENT = ((2*PI)/PCM_TABLE_SIZE);
signed int16 leftChannel = 0x0000;
signed int16 rightChannel = 0x0000;
unsigned int8 sample_resolution = 16; // 1 to 16
signed int32 sample_step;
signed int32 base;
signed int32 multiplier;
int8 down_sample_period = 1;
#define RED_LED PIN_C2
#define YELLOW_LED PIN_G9
#define GREEN_LED PIN_C14
#define BUTTON_1 PIN_B2
#define BUTTON_2 PIN_B3
#define BUTTON_3 PIN_B4
#define BUTTON_4 PIN_B5
void main()
{
unsigned int8 i;
setup_adc_ports(NO_ANALOGS);
setup_adc_ports2(NO_ANALOGS);
pcm_pos = 0;
sample_step = 1;
for(i = 0; i < sample_resolution - 1; i++)
{
sample_step *= 2;
}
base = MAXIMUM_VAL / sample_step;
delay_ms(600);
/* Start up the dci peripheral */
setup_dci((MULTICHANNEL_MODE | MULTI_DEVICE_BUS | UNDERFLOW_LAST |
DCI_SLAVE | DCI_CLOCK_INPUT | SAMPLE_RISING_EDGE),
DCI_1WORD_FRAME | DCI_16BIT_WORD | DCI_2WORD_INTERRUPT,
RECEIVE_SLOT0 | RECEIVE_SLOT1,
TRANSMIT_SLOT0 | TRANSMIT_SLOT1, 0);
/* Initialize the codec */
codec_initialize();
codec_setup_analog_path(DAC_SELECT | ADC_MIC_INPUT);
dci_start();
/* Generate since wave PCM table */
for(i = 0; i < 255; i++)
{
pcm_table[i] = 127 * sin(INCREMENT * i) + 128;
}
//make sure to init i = 255
pcm_table[i] = 127 * sin(INCREMENT * i) + 128;
setup_timer1(TMR_INTERNAL | TMR_DIV_BY_8, 10);
setup_timer2(TMR_INTERNAL | TMR_DIV_BY_64, 0x4000);
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_TIMER2);
enable_interrupts(INTR_GLOBAL);
while(TRUE)
{
codec_write_data16(&leftChannel, &rightChannel);
}
// lcd_init(); // Always call this first.
// lcd_putc("\fHello World\n");
// lcd_putc("Line Number 2");
// output_high(GREEN_LED);
}
#int_timer1
void timer1_isr()
{
/* Choose the next waveform value */
pcm_pos = (pcm_pos + 1) % PCM_TABLE_SIZE;
/* Generate and format the value */
leftChannel = pcm_table[pcm_pos];
multiplier = leftChannel / base;
leftChannel = base * multiplier;
rightChannel = leftChannel;
}
#int_timer2
void timer2_isr()
{
int8 i;
if(!input(BUTTON_4))
{
output_toggle(GREEN_LED);
if(sample_resolution > 1)
{
sample_resolution--;
}
sample_step = 1;
for(i = 0; i < sample_resolution -1; i++)
{
sample_step *= 2;
}
base = MAXIMUM_VAL / sample_step;
return;
}
if(!input(BUTTON_3))
{
output_toggle(YELLOW_LED);
if(sample_resolution < 16)
{
sample_resolution++;
}
sample_step = 1;
for(i = 0; i < sample_resolution - 1; i++)
{
sample_step *= 2;
}
base = MAXIMUM_VAL / sample_step;
return;
}
} |
I would really appreciate any help that anyone could give.
Thank you in advance,
Keith |
|
|
KeithA
Joined: 09 Mar 2009 Posts: 4
|
|
Posted: Thu Mar 12, 2009 9:33 am |
|
|
Thoughts from anyone? PCM Programmers, any ideas? After all, this board was developed by CCS (I think).
BTW, I am using PCIDE 4.085 purchased just a few weeks ago.
Thank,
Keith |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 12, 2009 10:51 am |
|
|
I don't work for CCS and I don't have the PCD compiler. That's why I
rarely answer PCD questions. |
|
|
KeithA
Joined: 09 Mar 2009 Posts: 4
|
|
Posted: Thu Mar 12, 2009 11:46 am |
|
|
My mistake PCM Programmer. Thank you for letting me know. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|