c - Expected a Declaration -


this first question (quite new coding) try , include info possible 'cos right i'm stumped!

i'm attempting write code create butterworth filter fit user input specifications. i'm using code composer 4.

having google away 54 errors have persistent 1 left:

"expected declaration" on line 27: if (n=1 && hpf=0) 

i have triple checked curly brackets, ideas?

edit:

hi again, help. have sorted old problems , more since have hit brick wall again; code won't write on (or create if file deleted) coffic.cof file. no errors appear file remains same. idea?

p.s. sorry previous code layout - better:

#include "dsk6713_aic23.h"      //codec-dsk support file uint32 fs=dsk6713_aic23_freq_8khz;  //set sampling rate # include <stdio.h> # include <math.h> # include <stdlib.h>  #define pi 3.1415927 #include "coffic.cof"  void main() {     double hpf, fs, fco, atn, fat, tp, k, ad, m, n, o, da, db, dc;     file *fp;     int c, d, e, f, g, h, i, q, r, s, t, u, v;     hpf = 0;            //for high-pass filter input 1, low-pass filter input 0     fs = 8000;          //input samping frequency here     fco = 2400;         //input cut-off frequency here     atn = 17;           //input attenuation (db) here     fat = 3500;         //input frequency of attenuation here     tp = 1/fs;     k = tan(pi*fco*tp);     ad = tan(pi*fat*tp);     m = (log10((pow(10,(atn/10)))-1))/(2*(log10(ad/k)));     o = abs(m);     n = ceil(o);      da = 1.414;     c = (pow(2,15)*k*k/(1+da*k+k*k));     d = (pow(2,15)*2*k*k/(1+da*k+k*k));     e = (pow(2,15)*k*k/(1+da*k+k*k));     q = (pow(2,15)*(2-2*k*k)/(1+da*k+k*k));     r = (pow(2,15)*(-1+k-k*k)/(1+da*k+k*k));      fp = fopen("u:\dsk6713\ivo\csp\coffic.cof", "w");     if (fp == null)     {         printf("error. unable open coffic.cof");         exit(0);     }      fprintf(fp, "int a[3]={%d, d%, %d};\n", c, d, e);     fprintf(fp, "int b[3]={1, d%, %d};\n", q ,r);     fprintf(fp, "int x[3]={0,0,0};\nint y[3]={0,0,0};\n");      fflush(fp);      fclose(fp);      comm_intr();                   //init dsk, codec, mcbsp     while(1);                      //infinite loop }  interrupt void c_int11()         //interrupt service routine  {     short input;     file *fp;     fp = fopen("u:\dsk6713\ivo\csp\coffic.cof", "r");     if (fp == null)     {         printf("error. unable open coffic.cof");         exit(0);     }      fclose(fp);      x[2]=x[1];     x[1]=x[0];     y[2]=y[1];     y[1]=y[0];      input=input_sample();     x[0]=input;      y[0]=a[0]*x[0]+a[1]*x[1]+a[2]*x[2]+b[1]*y[1]+b[2]*x[2];           y[0]=y[0]>>15;                           input=(short)y[0];     output_sample(input);   //output data       return; } 

also, looks program lacks main() function, having code @ top level (outside function) not allowed.

the main program should in function called:

int main(void) 

since execution start.

also, comparison operator in c spelled ==. single = assignment.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -