Hi Everbody I am facing problem while transfering data from ADC to DAC in between i have used some buffer logic after execusion it is not working or suddenly stop copying from ADC but What i have tried is copying directly from ADC to DAC is working. Plz give me some suggestion which are most valuable. #include <ADuC7026.h> #define HALFBLOCKLENGTH 128 volatile short buffer_full_flag; short adc_dac_cursor_index; short adc_dac_buf_index; int adc_buf[HALFBLOCKLENGTH*3]; int dac_buf[HALFBLOCKLENGTH*3]; int adc_buf_cursor0; int adc_buf_cursor1; int dac_buf_cursor0; int dac_buf_cursor1; //void speech1(int *out_buf,int *in_buf,int *noise,int *temp_buf,int p); int in_buf[HALFBLOCKLENGTH*2]; int out_buf[HALFBLOCKLENGTH*2]; int temp_buf[HALFBLOCKLENGTH]; int noise[HALFBLOCKLENGTH*2]; const int whanning[] = { 0x0000, 0x0009, 0x0027, 0x0058, 0x009d, 0x00f6, 0x0162, 0x01e2, 0x0275, 0x031c, 0x03d6, 0x04a2, 0x0582, 0x0675, 0x077b, 0x0893, 0x09be, 0x0afb, 0x0c4a, 0x0daa, 0x0f1d, 0x10a0, 0x1235, 0x13db, 0x1592, 0x1759, 0x1930, 0x1b17, 0x1d0d, 0x1f13, 0x2128, 0x234b, 0x257d, 0x27bd, 0x2a0a, 0x2c64, 0x2ecc, 0x3140, 0x33c0, 0x364b, 0x38e3, 0x3b85, 0x3e31, 0x40e8, 0x43a9, 0x4673, 0x4945, 0x4c21, 0x4f04, 0x51ee, 0x54e0, 0x57d9, 0x5ad7, 0x5ddc, 0x60e6, 0x63f4, 0x6707, 0x6a1d, 0x6d37, 0x7054, 0x7374, 0x7695, 0x79b8, 0x7cdb, 0x7fff, 0x8324, 0x8647, 0x896a, 0x8c8b, 0x8fab, 0x92c8, 0x95e2, 0x98f8, 0x9c0b, 0x9f19, 0xa223, 0xa528, 0xa826, 0xab1f, 0xae11, 0xb0fb, 0xb3de, 0xb6ba, 0xb98c, 0xbc56, 0xbf17, 0xc1ce, 0xc47a, 0xc71c, 0xc9b4, 0xcc3f, 0xcebf, 0xd133, 0xd39b, 0xd5f5, 0xd842, 0xda82, 0xdcb4, 0xded7, 0xe0ec, 0xe2f2, 0xe4e8, 0xe6cf, 0xe8a6, 0xea6d, 0xec24, 0xedca, 0xef5f, 0xf0e2, 0xf255, 0xf3b5, 0xf504, 0xf641, 0xf76c, 0xf884, 0xf98a, 0xfa7d, 0xfb5d, 0xfc29, 0xfce3, 0xfd8a, 0xfe1d, 0xfe9d, 0xff09, 0xff62, 0xffa7, 0xffd8, 0xfff6, 0xffff, 0xfff6, 0xffd8, 0xffa7, 0xff62, 0xff09, 0xfe9d, 0xfe1d, 0xfd8a, 0xfce3, 0xfc29, 0xfb5d, 0xfa7d, 0xf98a, 0xf884, 0xf76c, 0xf641, 0xf504, 0xf3b5, 0xf255, 0xf0e2, 0xef5f, 0xedca, 0xec24, 0xea6d, 0xe8a6, 0xe6cf, 0xe4e8, 0xe2f2, 0xe0ec, 0xded7, 0xdcb4, 0xda82, 0xd842, 0xd5f5, 0xd39b, 0xd133, 0xcebf, 0xcc3f, 0xc9b4, 0xc71c, 0xc47a, 0xc1ce, 0xbf17, 0xbc56, 0xb98c, 0xb6ba, 0xb3de, 0xb0fb, 0xae11, 0xab1f, 0xa826, 0xa528, 0xa223, 0x9f19, 0x9c0b, 0x98f8, 0x95e2, 0x92c8, 0x8fab, 0x8c8b, 0x896a, 0x8647, 0x8324, 0x7fff, 0x7cdb, 0x79b8, 0x7695, 0x7374, 0x7054, 0x6d37, 0x6a1d, 0x6707, 0x63f4, 0x60e6, 0x5ddc, 0x5ad7, 0x57d9, 0x54e0, 0x51ee, 0x4f04, 0x4c21, 0x4945, 0x4673, 0x43a9, 0x40e8, 0x3e31, 0x3b85, 0x38e3, 0x364b, 0x33c0, 0x3140, 0x2ecc, 0x2c64, 0x2a0a, 0x27bd, 0x257d, 0x234b, 0x2128, 0x1f13, 0x1d0d, 0x1b17, 0x1930, 0x1759, 0x1592, 0x13db, 0x1235, 0x10a0, 0x0f1d, 0x0daa, 0x0c4a, 0x0afb, 0x09be, 0x0893, 0x077b, 0x0675, 0x0582, 0x04a2, 0x03d6, 0x031c, 0x0275, 0x01e2, 0x0162, 0x00f6, 0x009d, 0x0058, 0x0027, 0x0009 }; void My_IRQ_Function(void); // IRQ Funtion Prototype void Setup(void); void delay(int); void speech(int * out, int * in, int * temp, const short halfblocklength) { int k; for (k=0; k<halfblocklength; k++) { out[k] = in[k]+ temp[k]; temp[k] = in[k+halfblocklength]; } } int main (void) { int n; for (n=0; n<HALFBLOCKLENGTH*3; n++) { adc_buf[n] = n; dac_buf[n] = 0; } for (n=0; n<HALFBLOCKLENGTH*2; n++) { in_buf[n] = 0; out_buf[n] = 0; noise[n] = 0; } for (n=0; n<HALFBLOCKLENGTH; n++) { temp_buf[n] = 0; } buffer_full_flag = 0; adc_dac_buf_index = 0; adc_dac_cursor_index = 0; adc_buf_cursor0 = HALFBLOCKLENGTH; adc_buf_cursor1 = 2*HALFBLOCKLENGTH; dac_buf_cursor0 = HALFBLOCKLENGTH; dac_buf_cursor1 = 2*HALFBLOCKLENGTH; Setup(); while(1) { if (buffer_full_flag == 1) { GP4DAT ^= 0x00040000; // Complement P4.2 buffer_full_flag = 0; for (n=0; n<HALFBLOCKLENGTH; n++) { in_buf[n] = (adc_buf[adc_buf_cursor1 + HALFBLOCKLENGTH-1-n] * whanning[n]) >> 16; // APPLY HANNING WINDOW in_buf[n+HALFBLOCKLENGTH] = (adc_buf[adc_buf_cursor0 + HALFBLOCKLENGTH-1-n] * whanning[n+HALFBLOCKLENGTH]) >> 16; // APPLY HANNING WINDOW } speech(out_buf, in_buf, temp_buf, HALFBLOCKLENGTH); for (n=0; n<HALFBLOCKLENGTH; n++) { dac_buf[dac_buf_cursor1 + HALFBLOCKLENGTH-1-n] = (out_buf[n])<<16; dac_buf[dac_buf_cursor0 + HALFBLOCKLENGTH-1-n] = (out_buf[n+HALFBLOCKLENGTH])<<16; } } } return 0 ; } void Setup(void) { //ADC configuration REFCON = 0x01; ADCCON = 0xE2; int time; time = 20000; while (time >=0) { time--; } ADCCP = 0x03; DAC0CON = 0x13; DAC0DAT = 0x08000000; // for test purposes only GP0CON = 0x10103000; GP4DAT = 0x04000000; IQ = My_IRQ_Function; FIQEN = ADC_BIT; T0LD = 282; T0CON = 0xC4; return ; } // Interrupt Service Rountine void My_IRQ_Function() { if ( (FIQSTA & ADC_BIT) != 0 ) { adc_buf[adc_dac_buf_index] =ADCDAT; DAC0DAT = dac_buf[adc_dac_buf_index]; adc_dac_cursor_index++; if (adc_dac_cursor_index>=HALFBLOCKLENGTH) { adc_dac_cursor_index = 0; adc_buf_cursor0 += HALFBLOCKLENGTH; if (adc_buf_cursor0 >= 3*HALFBLOCKLENGTH) { adc_buf_cursor0 = 0; } adc_buf_cursor1 += HALFBLOCKLENGTH; if (adc_buf_cursor1 >= 3*HALFBLOCKLENGTH) { adc_buf_cursor1 = 0; } dac_buf_cursor0 += HALFBLOCKLENGTH; if (dac_buf_cursor0 >= 3*HALFBLOCKLENGTH) { dac_buf_cursor0 = 0; } dac_buf_cursor1 += HALFBLOCKLENGTH; if (dac_buf_cursor1 >= 3*HALFBLOCKLENGTH) { dac_buf_cursor1 = 0; } buffer_full_flag = 1; } adc_dac_buf_index++; if (adc_dac_buf_index >= 3*HALFBLOCKLENGTH) { adc_dac_buf_index = 0; } } return ; } Thanks Hameed
You should try to run this program in the simulator. The simulator allows better analysis of the program behaviour. The ARM ADuC7024 is fully simulated and therefore it should be easy to find the problem. Reinhard