Reporting a bug

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
t@rek88
Posts: 24
Joined: 08 Mar 2013 22:44
Location: Kelibia, Tunisia
Contact:

Reporting a bug

#1 Post by t@rek88 » 22 May 2013 16:28

Hi,

I'm using STM32f407vg
When i was trying to simulate complex structure in signal processing project i found some problems
simply there is a portion of code that causes the problem:

Code: Select all

typedef struct {double r;double i;} Complex;

Complex CPLX(double _r, double _i){
  Complex c;
  c.r = _r;
  c.i = _i;
  return c;
}

Complex xAdd(Complex x,Complex y){
  return CPLX(x.r + y.r ,  x.i + y.i);
}

Complex xMul(Complex x,Complex y){
  return CPLX(x.r * y.r - x.i * y.i  ,   x.r * y.i + x.i * y.r);
}

void main() {
  Complex a,b,sum,mul;
  while(1){
    a = CPLX(1,0);        //  1
    b = CPLX(0,1);        //  i
    sum = xAdd(a,b);     // => should be : 1 + i
    mul = xMul(a,b);       // => should be : i
    Delay_ms(1000);
  }
}
but the result was not good
Attachments
debug result
debug result
Capture.PNG (83.1 KiB) Viewed 3187 times
Bouchkati Tarek
Tunisia
::::::::::::::::::::::::::::::::::::::::::::::::
Electronics & Embedded system engineering

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Reporting a bug

#2 Post by janko.kaljevic » 23 May 2013 09:39

Hello,

Thanks for reporting this.

I was able to reproduce the problem and we will provide solution for it as soon as possible.

At the moment you can declare your Complex values as globals and your code will work just fine.

Code: Select all

Complex a,b,sum,mul;
void main() {
  while(1){
  ....
Best regards.

prakob
Posts: 187
Joined: 24 Nov 2012 07:05
Location: Thailand

Re: Reporting a bug

#3 Post by prakob » 23 May 2013 11:52

Hi janko
It would be great if you test this issue with other mikroc pro compiler. Because this is an unexpected error for standard c programming.

Best Regards.

t@rek88
Posts: 24
Joined: 08 Mar 2013 22:44
Location: Kelibia, Tunisia
Contact:

Re: Reporting a bug

#4 Post by t@rek88 » 23 May 2013 14:23

Hi Janko,

I have found one different solution to escape this problem but it's still an error for standarts.

My solution:

Code: Select all

typedef struct {double r;double i;} Complex;

Complex CPLX(double _r, double _i){
  Complex c;
  c.r = _r;
  c.i = _i;
  return c;
}

Complex xAdd(Complex *x,Complex *y){
  return CPLX(x->r + y->r ,  x->i + y->i);
}

Complex xMul(Complex *x,Complex *y){
  return CPLX(x->r * y->r - x->i * y->i  ,   x->r * y->i + x->i * y->r);
}

void main() {
  Complex a,b,sum,mul;
  while(1){
    a = CPLX(1,0);//1
    b = CPLX(0,1);//i

    sum = xAdd(&a,&b);
    mul = xMul(&a,&b);
    
    Delay_ms(1000);
  }
}

hope you will find a solution as soon as possible.

regards,
Bouchkati Tarek
Tunisia
::::::::::::::::::::::::::::::::::::::::::::::::
Electronics & Embedded system engineering

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Reporting a bug

#5 Post by janko.kaljevic » 23 May 2013 15:08

Hello,

Yes this is also good solution.

Passing structures as pointer will generate smaller and more efficient code, so it is good suggestion.

At the moment this issue is bound for the 32 bit compilers and will be solved as soon as possible.

Best regards.

t@rek88
Posts: 24
Joined: 08 Mar 2013 22:44
Location: Kelibia, Tunisia
Contact:

Re: Reporting a bug

#6 Post by t@rek88 » 24 Jun 2013 20:10

Fed up waiting from mikroE to correct this bug issue
i 'll migrate to onother toolchain
:evil:
Bouchkati Tarek
Tunisia
::::::::::::::::::::::::::::::::::::::::::::::::
Electronics & Embedded system engineering

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Reporting a bug

#7 Post by janko.kaljevic » 25 Jun 2013 16:45

Hello,

The solution will be provided through the next release/live update of the compiler.

If you need prompt solution, please contact us through the ticket service and I will do my best in order to help you immediately.
http://www.mikroe.com/support/

Best regards.

Post Reply

Return to “mikroC PRO for ARM General”