cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 Matrix Computation

tjes50220
Associate
Posted on April 30, 2015 at 08:07

Hello, 

I use STM32F407  discovery board and keil uvision4.

        I want to do matrix communication but I meet the following weird problems.

        My code is as below.

float Num[2]= {0.000144962712488309, -0.000602215526678967};

    float Den[2]= {1, -5.62630205892449};   

      

  float ACCd[2];

        printf(''ACC 3 \n'');

        for (int i=0; i<2; i++)

        {

        ACCd[i]=Num[i]*Den[i];

        }

      printf(''ACC 4 \n'');

      It can compile but I can't see any result even the print of  

ACC 3

.

    When I modified the code to 

     

float Num[2]= {0.000144962712488309, -0.000602215526678967};

     

float Den[2]= {1, -5.62630205892449};   

      

float ACCd[2];

        printf(''ACC 3 \n'');

       ACCd[0]=Num[0]*Den[0];

       ACCd[1]=Num[1]*Den[1];

      printf(''ACC 4 \n'');

       And it can work fine. Do I miss some constraints about the ST?

Thanks

#stm32 #matrix
3 REPLIES 3
AvaTar
Lead
Posted on April 30, 2015 at 12:15

I don't see a grave issue in the provided code.

Have turned off any optimisation, and did you try to single-step in a debugger ?

However, there are two issues you migth stumble upon later:

    float Num[2]= {0.000144962712488309, -0.000602215526678967};

 

 

First, these are not floating point, but double constants. Make it 'float' with an 'f' at the end (like '0.000144

f

'), otherwise this will impact performance.

Second, 'float' is not capable of holding the precision you specified. Check if/how this affects your algorithm.

Posted on April 30, 2015 at 13:37

Not sure I like the C++ syntax, and the lack of real context of the code, but it looks reasonable enough.

I'd make sure I pulled in math.h, check the MicroLib, FPU and optimization options.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
tjes50220
Associate
Posted on May 03, 2015 at 17:47

I found that the original sample code didn't enable the fpu.

I just need to enable.