TODOPIC

Microcontroladores PIC => dsPIC => Mensaje iniciado por: reyes33d88 en 16 de Enero de 2013, 20:01:54

Título: Problemas con Filter Desing Tool de Mikro C para dsPICS
Publicado por: reyes33d88 en 16 de Enero de 2013, 20:01:54
Que tal amigos, saludos desde México, alguno de ustedes ha utilizado el Filter Desing Tool de Mikro C para dsPICS?, necesito programar un filtro, pero a la hora de compilarlo, me dice que existen varios errores, alguno de ustedes ya lo ha hecho?, muchas gracias, saludos, les dejo el código fuente con los errores que marca, saludos!!!


// This code was generated by filter designer tool by mikroElektronika
// Date/Time: 16/01/2013 12:00:23 p.m.
// Support info: http://www.mikroe.com

// Device setup:
//     Device name: P33FJ12GP201
//     Device clock: 010.000000 MHz
//     Dev. board: LV 24-33A
//     Sampling Frequency: 700000 Hz
// Filter setup:
//     Filter kind: FIR
//     Filter type: Highpass filter
//     Filter order: 20
//     Filter window: Blackman
//     Filter borders:
//       Wstop: 120000 Hz
const unsigned BUFFFER_SIZE  = 32;
const unsigned FILTER_ORDER  = 20;

const unsigned COEFF_B[FILTER_ORDER+1] = {
      0x0000, 0x0003, 0xFFDA, 0xFF70, 0xFFC2, 0x022B,
      0x04C6, 0x00D7, 0xF190, 0xDD8C, 0x541D, 0xDD8C,
      0xF190, 0x00D7, 0x04C6, 0x022B, 0xFFC2, 0xFF70,
      0xFFDA, 0x0003, 0x0000};
     
const unsigned int
      load_pin               =8, //DAC LOAD PIN
      CS_PIN                 =7;//DAC CS pin
unsigned inext;                       // Input buffer index
ydata unsigned input[BUFFFER_SIZE];   // Input buffer, must be in Y data space
unsigned CurrentValue;

/* This is ADC interrupt handler.
 Analog input is sampled and the value is stored into input buffer.
 Input buffer is then passed through filter.
 Finally, the resulting output sample is sent to DAC.
 */
void ADC1Int() org IVT_ADDR_ADC1INTERRUPT
{ // ADC interrupt handler
  //unsigned CurrentValue;
  input[inext] = ADCBUF0;                 // Fetch sample

  CurrentValue = FIR_Radix(FILTER_ORDER+1,// Filter order
                            COEFF_B,      // b coefficients of the filter
                            BUFFFER_SIZE, // Input buffer length
                            input,        // Input buffer
                            inext);       // Current sample

  inext = (inext+1) & (BUFFFER_SIZE-1);   // inext = (inext + 1) mod BUFFFER_SIZE;
 
}
const unsigned //int
  //cs_Pin = 0;                             // CS enable for DAC
 

 
SI2BUF = 0x3000 | CurrentValue;       // Write CurrentValue to DAC (0x3 is required by DAC)
  while (SPITBF_SPI2STAT_bit){           // Wait for SPI module to finish write operation
    asm nop;

  load_Pin  = 0;                           // Load data in DAC
  Delay_us(2);
  load_Pin  = 1;

  cs_Pin    = 1;                           // CS disable for DAC

  AD1IF_bit = 0;                           // Clear AD1IF
}//~

/* This is Timer1 interrupt handler.
   It is used to start ADC at periodic intervals.
 */
void Timer1Int() org IVT_ADDR_T1INTERRUPT { // Timer1 interrupt handler

 if (DONE_bit){                          // If ADC is not busy
    SAMP_bit  = 1;                       // Start new sample
  }
  LATD = PORTD ^ 0xFFFF;                 // You can put oscilloscope on PORTD
                                         //  to measure sampling frequency
  T1IF_bit    = 0;
}//~

/* The main program starts here.
   Firstly, hardware peripherals are initialized and then
   the program goes to an infinite loop, waiting for interrupts. */
void main() {
  TRISD = 0;
  // DAC setup
  loadPinDir = 0;                        // LOAD pin
  csPinDir   = 0;                        // CS pin
  csPin      = 1;                        // Set CS to inactive
  loadPin    = 1;                        // Set LOAD to inactive

  // SPI setup
  SPI2_Init_Advanced(_SPI_MASTER, _SPI_16_BIT,  _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_1,
                     _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH,
                     _SPI_ACTIVE_2_IDLE);

  inext  = 0;                            // Initialize buffer index
  Vector_Set(input, BUFFFER_SIZE, 0);    // Clear input buffer

  TRISB   = 0xFFFF;                      // Use PORTB for input signal
  ADCON1  = 0x00E2;                      // Auto-stop sampling, unsigned integer out
  ADCON2  = 0x0000;
  ADCON3  = 0x0203;                      // Sampling time= 3*Tad, minimum Tad selected
  ADPCFG  = 0x0000;                      // Configure PORTB as ADC input port
  ADCHS   = 0x000A;                      // Sample input on RB10
  ADCSSL  = 0;                           // No input scan
  ADPCFG  = 0x0000;                      // Configure PORTB as analog ADC input port

  // Interrupts setup
  IFS0    = 0;                           // Clear interrupt flags
  IFS1    = 0;                           // Clear interrupt flags
  IFS2    = 0;                           // Clear interrupt flags
  NSTDIS_bit = 1;                        // Nested interrupts DISABLED
  INTCON2    = 0;                        // Other interrupt settings
  T1IE_bit   = 1;                        // Timer1 and
  ADIE_bit   = 1;                        // ADC interrupts ENABLED
  T1IP0_bit  = 1;                        // Timer1 interrupt priority level = 1
  ADIP1_bit  = 1;                        // ADC interrupt priority level = 1

  PR1        = 0x007D;                   // Sampling ~= 80 kHz. The value of 250 is calculated for 80MHz clock.
  TON_bit    = 1;                        // Start Timer1, internal clock FCY, prescaler 1:1

  ADON_bit   = 1;                        // ADC On
  SAMP_bit   = 1;                        // Start Sampling
  while (1);                             // Infinite loop,
                                         //   wait for interrupts
}//~!

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ERRORES:

57 375 Const expression expected MyProject.c
58 371 Specifier needed MyProject.c
58 396 Invalid declarator expected'(' or identifier MyProject.c
61 318 Assigning to non-lvalue 'load_pin' MyProject.c
63 318 Assigning to non-lvalue 'load_pin' MyProject.c
65 318 Assigning to non-lvalue 'CS_PIN' MyProject.c
78 324 Undeclared identifier 'LATD' in expression MyProject.c
78 324 Undeclared identifier 'PORTD' in expression MyProject.c
87 324 Undeclared identifier 'TRISD' in expression MyProject.c
89 324 Undeclared identifier 'loadPinDir' in expression MyProject.c
90 324 Undeclared identifier 'csPinDir' in expression MyProject.c
91 324 Undeclared identifier 'csPin' in expression MyProject.c
92 324 Undeclared identifier 'loadPin' in expression MyProject.c
95 324 Undeclared identifier 'SPI2_Init_Advanced' in expression MyProject.c
103 324 Undeclared identifier 'ADCON1' in expression MyProject.c
104 324 Undeclared identifier 'ADCON2' in expression MyProject.c
105 324 Undeclared identifier 'ADCON3' in expression MyProject.c
107 324 Undeclared identifier 'ADCHS' in expression MyProject.c
108 324 Undeclared identifier 'ADCSSL' in expression MyProject.c
114 324 Undeclared identifier 'IFS2' in expression MyProject.c
118 324 Undeclared identifier 'ADIE_bit' in expression MyProject.c
120 324 Undeclared identifier 'ADIP1_bit' in expression MyProject.c
0 102 Finished (with errors): 16 ene 2013, 17:00:23 MyProject.mcpds