This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C6713 DSP (CCS3.1v) graphing error

I would realize the AD&DA using a daughterboard.

I input the signal of square wave from the function generator. (10Hz, 5vpp, offset 0) 

I wanted to confirm the input signal the board receiving. So I viewed the configure the square wave. but something weird...

/*******************************************************************************
* File    : ex08_adc.c
* Purpose : AD7655(16bit, 4ch ADC) device usage example
*           also including ex01_led, ex02_uart, ex03_usb, ex04_tcpip, ex05_dout
*           examples running on C6713B internal RAM
* Company : RealSYS
* Date    : 2007.11.05
* Author  : R.N.K
* History :
*******************************************************************************/

#include "c6713.h"

#pragma CODE_SECTION(timer0_ISR, ".iram_func")
#pragma CODE_SECTION(uart_ISR, ".iram_func")
#pragma CODE_SECTION(usb_ISR, ".iram_func")
#pragma CODE_SECTION(tcpip_ISR, ".iram_func")
#pragma CODE_SECTION(adc_ISR, ".iram_func")
//////////////////////////////////////////////////////////////////////////////////

#define DSK6713_AIC23_INPUT_MIC 0x0015
#define DSK6713_AIC23_INPUT_LINE 0x0011

#define LEFT  0
#define RIGHT 1
#define NOISELEVEL 2000

#define SWITCH_UP 1
#define SWITCH_DOWN 0

#define SLENGTH 1600
#define WLENGTH 1600
#define MU_S 0.05
#define MU_W 0.001
#define EPSILON 1000
#define MAX_VALUE 30000

//Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
//Uint16 inputsource=DSK6713_AIC23_INPUT_LINE;
float gain;
unsigned char codec, channel, input_source, flag = 0;
unsigned int data;
volatile union {
 unsigned int uint;
 short channel[2];
 } TxData0, TxData1, RxData0, RxData1;

unsigned int overall_counter = 0;
int fb=0;
volatile Uint16 sleepCount = 0;
unsigned int counter = 0;
unsigned int int_counter = 0;

extern far void vectors();

Uint16 t_cnt=0;
Uint16 adc_data[8];

BOOL is_comio_exist=FALSE;
BOOL is_adcio_exist=FALSE;
///////////////////////////////////////////////////////////////////////////////////////
///// 변수 설정 /////
int i;
int count=0;

// 이차경로 추정 //
float off_input[SLENGTH];
float ss[SLENGTH];
float off_desired, off_error;
float off_out0, off_out1;
float off_mu;

// ANC 변수 //
float x_vec[WLENGTH];
float xsw_vec[WLENGTH];
float ww[WLENGTH];
float y_out0, y_out1, y_out;
float fx0, fx1;
float sigma_x;
float alpha, alpha_c;
float mu;
float e_temp;

void Init_variable()
{
 for ( i=0 ; i<SLENGTH ; i++ )
 {
  off_input[i] = 0.0;
  ss[i] = 0.0;
 }
 off_desired = 0.0;
 off_error = 0.0;
 off_out0 = 0.0;
 off_out1 = 0.0;
 off_mu = 0.0;
 count = 0;
 for ( i=0 ; i<WLENGTH ; i++ )
 {
  x_vec[i] = 0.0;
  xsw_vec[i] = 0.0;
  ww[i] = 0.0;
 }
 y_out0 = 0.0;
 y_out1 = 0.0;
 y_out = 0.0;
 fx0 = 0.0;
 fx1 = 0.0;
 sigma_x = 0.0;
 alpha = 1-1.0/WLENGTH;
 alpha_c = 1.0/WLENGTH;
 mu = 0;
 e_temp = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Modified when 2011.03.31 by R.N.K
// 추가한 확장 AD_DA 옵션 보드 장착 여부
Uint16 adc_data2[8];
BOOL is_ex_adcio_exist=FALSE;
//--------------------------------------

extern BOOL s0_init;      // Socket 0 initialization status flag
extern BOOL s0_connected; // Socket 0 connection status flag

void main(void){

        Init_variable();
   
 // All interrupt disable
 INT_reset_All();

 // initialize PLL
 init_pll();
  
 // initialize Support Device Configuration
 init_device_config();

 // initialize GPIO
 init_gpio();

 // initialize EMIF
 init_emif();
 
 // initialize interrupt vector table
 INT_set_Vectors(vectors);
 
 // set Timer0 interrupt selector
 INT_map(INT_14_BIT, INT_14_MASK, INT_TINT0);  // set timer0 interrupt to INT14
 INT_reset(INT_14_BIT);

 // set UART receiver full interrupt(/INT6) selector
 INT_map(INT_06_BIT, INT_06_MASK, INT_GPINT6); // set UART receiver full interrupt to INT6
 INT_reset(INT_06_BIT);

 // set USB receiver full interrupt(/INT4) selector
 INT_map(INT_04_BIT, INT_04_MASK, INT_GPINT4); // set USB receiver full interrupt to INT4
 INT_reset(INT_04_BIT);
 
 // set W3150A+ interrupt(/INT7) selector
 INT_map(INT_07_BIT, INT_07_MASK, INT_GPINT7); // set W3150A+ interrupt to INT7
 INT_reset(INT_07_BIT);
 
 // set ADC /BUSY0 interrupt(/INT5) selector
 INT_map(INT_05_BIT, INT_05_MASK, INT_GPINT5); // set ADC /BUSY0 interrupt to INT5
 INT_reset(INT_05_BIT);

 // global interrupt is enabled 
 INT_global_Enable();
 INT_nmi_Enable();
 
 // Turn off DSK6713 All On-Board Leds
 DSK6713_LedAllOff();
 
 // Check COM_IO, ADC_IO daughter card connection
 is_comio_exist = Get_COMIO_Exist();
 is_adcio_exist = Get_ADCIO_Exist();
 
 // Modified when 2011.03.31 by R.N.K
 is_ex_adcio_exist = Get_EX_ADCIO_Exist();

 // initialize Timer0 with 50msec period
 init_timer0(50);
 
 if(is_comio_exist){
  // initialize UART(16C554) with 115200 bps
  init_uart0(BPS_115200);
  init_uart1(BPS_115200);
  init_uart2(BPS_115200);
  init_uart3(BPS_115200);
  
  // initialize USB
  init_usb();
  
  // initialize LAN
  init_lan();
  s0_init = init_socket0();
 }
 
 // Modified when 2011.03.31 by R.N.K
 if(is_adcio_exist || is_ex_adcio_exist){
  // Start ADC conversion(5ns)
  if(is_adcio_exist) Start_ADC_Conversion();
  if(is_ex_adcio_exist) Start_EX_ADC_Conversion();

  asm(" nop ");

  if(is_adcio_exist) Stop_ADC_Conversion();
  if(is_ex_adcio_exist) Stop_EX_ADC_Conversion();
 }
 
 // enable interrupt
 INT_enable(INT_14_BIT);

 if(is_comio_exist){
  INT_enable(INT_06_BIT);
  INT_enable(INT_04_BIT);
  if(s0_init) INT_enable(INT_07_BIT);
 }
 
 if(is_adcio_exist){
  INT_enable(INT_05_BIT);
 }

 while(TRUE){
  if(is_comio_exist){
   // When initialization is failed, retry socket 0 initialization action
   if(!s0_init){
    s0_init = init_socket0();
    if(s0_init) INT_enable(INT_07_BIT); 
   }
  }

  if(is_adcio_exist){
               
                f = 500;
         out_time = (16000/f)*2;

                    if (off_desired > 50)
                        {  
                          if (count <= out_time)
                 {
                            DAC_DATA0 = 3000*sin(2*PI*(f)*count/16000)>>4;
                     count++;
                       }
                    else
                       {
                            DAC_DATA0 = 0>>4;
         }
   }
                     else
                        {
     count=0;   
            DAC_DATA0 = 0>>4;
   }

   DAC_Output_Enable();
   asm(" nop ");
   DAC_Output_Disable();
  }

  // Modified when 2011.03.31 by R.N.K
  if(is_ex_adcio_exist){
   EX_DAC_DATA0 = adc_data2[0]>>4;
   EX_DAC_DATA1 = adc_data2[1]>>4;
   EX_DAC_DATA2 = adc_data2[2]>>4;
   EX_DAC_DATA3 = adc_data2[3]>>4;
   EX_DAC_DATA4 = adc_data2[4]>>4;
   EX_DAC_DATA5 = adc_data2[5]>>4;
   EX_DAC_DATA6 = adc_data2[6]>>4;
   EX_DAC_DATA7 = adc_data2[7]>>4;
   
   EX_DAC_Output_Enable();
   asm(" nop ");
   EX_DAC_Output_Disable();
  }
 }
}

interrupt void timer0_ISR(void){
 t_cnt++;
 DSK6713_LedData((Uint8)(t_cnt & 0xff));

 if(is_comio_exist){
  Set_COMIO_DOUT(~t_cnt); 
 }
 if(is_adcio_exist){
  Set_ADCIO_DOUT(~t_cnt);
 }

 // Modified when 2011.03.31 by R.N.K
 if(is_ex_adcio_exist){
  Set_EX_ADCIO_DOUT(~t_cnt);
 }
}

interrupt void uart_ISR(void){
 while(TRUE){
  if(bit_is_clear(GPVAL_REG, 6)){
   while(bit_is_set(UART0_LSR_REG, LSR_RXF_FLAG_BIT)){ // UART0 수신 데이터 처리
    uart0_rxd_handle(UART0_RXD_REG); 
   }
   
   while(bit_is_set(UART1_LSR_REG, LSR_RXF_FLAG_BIT)){ // UART1 수신 데이터 처리
    uart1_rxd_handle(UART1_RXD_REG);
   }

   while(bit_is_set(UART2_LSR_REG, LSR_RXF_FLAG_BIT)){ // UART2 수신 데이터 처리
    uart2_rxd_handle(UART2_RXD_REG);
   }

   while(bit_is_set(UART3_LSR_REG, LSR_RXF_FLAG_BIT)){ // UART3 수신 데이터 처리
    uart3_rxd_handle(UART3_RXD_REG);
   }
  }
  else break;
 }
}

interrupt void usb_ISR(void){
 while(TRUE){
  if(bit_is_clear(GPVAL_REG, 4)){
   usb_rxd_handle(USB_DATA_REG);
  }
  else break;
 }
}

interrupt void tcpip_ISR(void){
Uint8 intID, s0_status;

 while(TRUE){
  if(bit_is_clear(GPVAL_REG, 7)){
   if(bit_is_set(LAN_IR_REG, INT_S0_BIT)){     // Socket 0 interrupt occurs
    intID = LAN_S0_IR_REG;
    s0_status = LAN_S0_SR_REG;
    if(s0_init) socket0_int_handler(intID, s0_status);

    // clear interrupt flag
    if(intID != 0) LAN_S0_IR_REG = intID;
   }
   else if(bit_is_set(LAN_IR_REG, INT_S1_BIT)){   // Socket 1 interrupt occurs
    // not used in this example
    intID = LAN_S1_IR_REG;

    // clear interrupt flag
    if(intID != 0) LAN_S1_IR_REG = intID;
   }
   else if(bit_is_set(LAN_IR_REG, INT_S2_BIT)){   // Socket 2 interrupt occurs
    // not used in this example
    intID = LAN_S2_IR_REG;
    
    // clear interrupt flag
    if(intID != 0) LAN_S2_IR_REG = intID;
   }
   else if(bit_is_set(LAN_IR_REG, INT_S3_BIT)){   // Socket 3 interrupt occurs
    // not used in this example
    intID = LAN_S3_IR_REG;
    
    // clear interrupt flag
    if(intID != 0) LAN_S3_IR_REG = intID;
   }
   else if(bit_is_set(LAN_IR_REG, INT_PPPOE_BIT)){   // PPPoE Close interrupt occurs
    // not used in this example

    // clear interrupt flag
    set_bit(LAN_IR_REG, INT_PPPOE_BIT);
   }
   else if(bit_is_set(LAN_IR_REG, INT_UNREACH_BIT)){  // Destination unreachable interrupt occurs
    // not used in this example

    // clear interrupt flag
    set_bit(LAN_IR_REG, INT_UNREACH_BIT);
   }
   else if(bit_is_set(LAN_IR_REG, INT_CONFLICT_BIT)){  // IP Conflict interrupt occurs
    // not used in this example

    // clear interrupt flag
    set_bit(LAN_IR_REG, INT_CONFLICT_BIT);
   }
  }
  else break;
 }
}

// Modified when 2011.03.31 by R.N.K
interrupt void adc_ISR(void){
 if(bit_is_clear(GPVAL_REG, 5)){
  if(is_adcio_exist) while(Get_ADC_Busy());
  if(is_ex_adcio_exist) while(Get_EX_ADC_Busy());

  if(is_adcio_exist){
   if(Get_ADC_A0()){ // High
    adc_data[1] = ADC_DATA01;
    adc_data[3] = ADC_DATA23;
    adc_data[5] = ADC_DATA45;
    adc_data[7] = ADC_DATA67;
    
    Set_Low_ADC_A0();
   }
   else{ // Low
    adc_data[0] = ADC_DATA01;
    adc_data[2] = ADC_DATA23;
    adc_data[4] = ADC_DATA45;
    adc_data[6] = ADC_DATA67;
    
    Set_High_ADC_A0();
   }

                  off_desired = adc_data[0];
 
           //Signal confirm//
           //Signal confirm//
           x_vec[0] = off_desired;

           for (i=WLENGTH-1; i>=0; i--)
            {
        x_vec[i] = x_vec[i-1];
            }
          }

  if(is_ex_adcio_exist){
   if(Get_EX_ADC_A0()){ // High
    adc_data2[1] = EX_ADC_DATA01;
    adc_data2[3] = EX_ADC_DATA23;
    adc_data2[5] = EX_ADC_DATA45;
    adc_data2[7] = EX_ADC_DATA67;
    
    Set_Low_EX_ADC_A0();
   }
   else{ // Low
    adc_data2[0] = EX_ADC_DATA01;
    adc_data2[2] = EX_ADC_DATA23;
    adc_data2[4] = EX_ADC_DATA45;
    adc_data2[6] = EX_ADC_DATA67;
    
    Set_High_EX_ADC_A0();
   }
  }

  // Start ADC conversion(5ns)
  if(is_adcio_exist) Start_ADC_Conversion();
  if(is_ex_adcio_exist) Start_EX_ADC_Conversion();

  asm(" nop ");

  if(is_adcio_exist) Stop_ADC_Conversion();
  if(is_ex_adcio_exist) Stop_EX_ADC_Conversion();
 }
}

There are many DSP data types I can select like 32bit singed integer, 16...8... and 32 IEEE floating .. and so on.

What should I select?

The company member delivered the Daughtercard said the Input signal would be treated as 16 bit and the Output signal would be treated as 12 bit.

But someone said me the DSP data type for the graphing is under the header file and c file.

Anyone else can tell me that 

I made some mistake in code or graph setting? or... any other mistakes?

have a nice day!!  

  • Yeonuk Seong said:

    There are many DSP data types I can select like 32bit singed integer, 16...8... and 32 IEEE floating .. and so on.

    What should I select?

    The DSP data type setting in the graph properties should generally be set to match with how the variable is defined in your code.

    Also, the version of CCS you are using (v3.1) is very old and no longer supported, so please understand that the amount of support we can provide for this version is very limited.