Hi,
I would like to say that I am new to programming with hardware. I am currently programming on a TSM320C6713 DSK on CCS v3.3. I'm trying to take an analog input, convert it to a value that I can use to create a PWM. I have several problems with the code.
First, when I call any functions from the c6713dskinit.c source file, my program falls in an infinite loop somewhere in the disassembly. I don't know why it does, is if that my file is outdated or corrupted? There's no errors in building the code.
Second, I tried to use this:
union {Uint32 combo; short channel[2];} temp;
temp.combo = MCBSP_read(DSK6713_AIC23_DATAHANDLE);
to store the input, but it doesn't work. Do I miss something with that?
I read many treads and documentations without find a example that works with my project. I would apreciate any tips, links, examples that would help me get this done.
It has been modified several times, but here is my code:
#include "stdio.h"
#include "dsk6713.h"
#include "dsk6713_dip.h"
#include "dsk6713_led.h"
#include "dsk6713_aic23.h"
#include <csl.h>
#include <csl_timer.h>
#include <csl_irq.h>
#include <csl_gpio.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
#define CTL1 0x01980000 //Adress des registre utiles pour le programme
#define CNT1 0x01980008
#define PRD1 0x01980004
#define GPEN 0x01B00000
#define GPDIR 0x01B00004
#define GPVAL 0x01B00008
#define GPPOL 0x01B00024
#define DSK6713_AIC23_INPUT_MIC 0x0015
#define DSK6713_AIC23_INPUT_LINE 0x0011
#define CHIP_6713 1
#define squareTableLen 800
#define table_size (int)0x100 //size of table = 256
#define LEFT 0
#define RIGHT 1
int data_table[table_size]; //data table array
Uint16 inputsource=DSK6713_AIC23_INPUT_LINE;
unsigned int intTemp;
short q = 0;
short x = 0;
short y = 0;
short z = 0;
short w = 0;
short length = 99;
short v = 0;
short loop_index = 0;
short table[64] = {0};
short ttick = 0;
int i = 0;
short loop = 0; //table index
short gain =1;
short frequency = 1;
short square_table[squareTableLen]={0}; // table initialization
union {Uint32 combo; short channel[2];} AIC23_data;
void dsk_init(void) //interrupt service routine
{
intTemp = *(unsigned int *)GPEN;
intTemp = intTemp|0x07B;
*(unsigned int*)GPEN = intTemp; //Active la pin 3
intTemp = *(unsigned int *)GPDIR;
intTemp = intTemp & 0xFFFFFF8F;
intTemp = intTemp | 0x0000000B; //Sélectionne la pin 3 comme output
*(unsigned int*)GPDIR = intTemp;
*(unsigned int *) PRD1 = 3516; // On configure le timer0 à 8 KHz
*(unsigned int *) CTL1 = 0x3C7; // Configure le timer0 en osc interne
}
interrupt void c_int11() //interrupt service routine
{
} // end of interrpt routine
void main(void)
{
DSK6713_init();
dsk_init();
DSK6713_DIP_init(); //Initialize DIP switches
DSK6713_LED_init(); //Initialize LEDs
ttick = 0;
for(q = 0; q < 4; q++)
{
printf("Hello World!\n");
}
while(1)
{
int t;
AIC23_data.combo = MCBSP_read(DSK6713_AIC23_DATAHANDLE);
t = (AIC23_data.channel[0]*100)/35;
x = (t*2860)/100; // Le nombre d'échantillion donne la période du PWM
v = 2860 - x;
for(y = 0; y < x; y++)
{
intTemp = *(unsigned int *)GPVAL;
intTemp = intTemp|0x00000004;
*(unsigned int*)GPVAL = intTemp; //Active la pin 3
w++;
}
for(z = 0; z < v; z++)
{
intTemp = *(unsigned int *)GPVAL;
intTemp = intTemp & 0x00000000;
*(unsigned int*)GPVAL = intTemp;
w++;
}
if(DSK6713_DIP_get(0)==1)
{
DSK6713_LED_on(3);
intTemp = *(unsigned int *)GPVAL;
intTemp = intTemp|0x00000003;
*(unsigned int*)GPVAL = intTemp;
}
else
{
DSK6713_LED_off(3);
intTemp = *(unsigned int *)GPVAL;
intTemp = intTemp | 0x0000000B;
intTemp = intTemp & 0xFFFFFFFC;
*(unsigned int*)GPVAL = intTemp;
}
if(DSK6713_DIP_get(1)==0)
{
DSK6713_LED_on(2);
}
else
{
DSK6713_LED_off(2);
}
}
}
void timer_isr(void)
{
ttick++;
return;
}