Jump to content

monpetit

Members
  • Content Count

    7
  • Joined

  • Last visited


Reputation Activity

  1. Like
    monpetit got a reaction from gangul in using CMSIS DSP library dsplib-cm4f.lib in Energia   
    You need the CMSIS DSP library compiled with gcc, that is "libarm_cortexM4lf_math.a".
    Then...
     
    1. make a directory for the CMSIS DSP libraries to include your energia programs. For example, 
       cd ~/Energia/libraries
       mkdir arm_math
     
    2. put the CMSIS DSP header files to library directory.
       header files: core_cm4.h, core_cm4_simd.h, core_cmFunc.h, core_cmInstr.h, arm_common_tables.h, arm_const_structs.h, arm_math.h
     
    3. put library file to suitable path.
       cp libarm_cortexM4lf_math.a  energia-0101E0009/hardware/tools/lm4f/arm-none-eabi/lib/thumb/armv7e-m/fpu/fpv4-sp-d16
     
    4. edit your ld script "dev/energia-0101E0009/hardware/lm4f/cores/lm4f/lm4fcpp.ld" to link math library. Append two line like this,
     


       /* Library configurations */
       GROUP(libgcc.a libc.a libm.a libarm_cortexM4lf_math.a)

     
    5. test your code.



    #ifndef __FPU_PRESENT
    #define __FPU_PRESENT 1
    #endif

    #include <arm_math.h>
    #include <arm_common_tables.h>
    #include <arm_const_structs.h>

    #define USE_STATIC_INIT

    /* ----------------------------------------------------------------------
    ** Global defines
    ** ------------------------------------------------------------------- */

    #define TEST_LENGTH_SAMPLES (20*4)

    /* ----------------------------------------------------------------------
    ** List of Marks scored by 20 students for 4 subjects
    ** ------------------------------------------------------------------- */
    const float32_t testMarks_f32[TEST_LENGTH_SAMPLES] =
    {
    42.000000, 37.000000, 81.000000, 28.000000,
    83.000000, 72.000000, 36.000000, 38.000000,
    32.000000, 51.000000, 63.000000, 64.000000,
    97.000000, 82.000000, 95.000000, 90.000000,
    66.000000, 51.000000, 54.000000, 42.000000,
    67.000000, 56.000000, 45.000000, 57.000000,
    67.000000, 69.000000, 35.000000, 52.000000,
    29.000000, 81.000000, 58.000000, 47.000000,
    38.000000, 76.000000, 100.000000, 29.000000,
    33.000000, 47.000000, 29.000000, 50.000000,
    34.000000, 41.000000, 61.000000, 46.000000,
    52.000000, 50.000000, 48.000000, 36.000000,
    47.000000, 55.000000, 44.000000, 40.000000,
    100.000000, 94.000000, 84.000000, 37.000000,
    32.000000, 71.000000, 47.000000, 77.000000,
    31.000000, 50.000000, 49.000000, 35.000000,
    63.000000, 67.000000, 40.000000, 31.000000,
    29.000000, 68.000000, 61.000000, 38.000000,
    31.000000, 28.000000, 28.000000, 76.000000,
    55.000000, 33.000000, 29.000000, 39.000000
    };


    /* ----------------------------------------------------------------------
    * Number of subjects X 1
    * ------------------------------------------------------------------- */
    const float32_t testUnity_f32[4] =
    {
    1.000, 1.000, 1.000, 1.000
    };


    /* ----------------------------------------------------------------------
    ** f32 Output buffer
    ** ------------------------------------------------------------------- */
    static float32_t testOutput[TEST_LENGTH_SAMPLES];


    /* ------------------------------------------------------------------
    * Global defines
    *------------------------------------------------------------------- */
    #define NUMSTUDENTS 20
    #define NUMSUBJECTS 4

    /* ------------------------------------------------------------------
    * Global variables
    *------------------------------------------------------------------- */

    uint32_t numStudents = 20;
    uint32_t numSubjects = 4;
    float32_t max_marks, min_marks, mean, _std, var;
    uint32_t student_num;

    /* ----------------------------------------------------------------------------------
    * Main f32 test function. It returns maximum marks secured and student number
    * ------------------------------------------------------------------------------- */

    void setup()
    {
    Serial.begin(9600);
    }

    void loop()
    {

    #ifndef USE_STATIC_INIT

    arm_matrix_instance_f32 srcA;
    arm_matrix_instance_f32 srcB;
    arm_matrix_instance_f32 dstC;

    /* Input and output matrices initializations */
    arm_mat_init_f32(&srcA, numStudents, numSubjects, (float32_t *)testMarks_f32);
    arm_mat_init_f32(&srcB, numSubjects, 1, (float32_t *)testUnity_f32);
    arm_mat_init_f32(&dstC, numStudents, 1, testOutput);

    #else

    /* Static Initializations of Input and output matrix sizes and array */
    arm_matrix_instance_f32 srcA = {
    NUMSTUDENTS, NUMSUBJECTS, (float32_t *)testMarks_f32
    };
    arm_matrix_instance_f32 srcB = {
    NUMSUBJECTS, 1, (float32_t *)testUnity_f32
    };
    arm_matrix_instance_f32 dstC = {
    NUMSTUDENTS, 1, testOutput
    };

    #endif


    /* ----------------------------------------------------------------------
    *Call the Matrix multiplication process function
    * ------------------------------------------------------------------- */
    arm_mat_mult_f32(&srcA, &srcB, &dstC);

    /* ----------------------------------------------------------------------
    ** Call the Max function to calculate max marks among numStudents
    ** ------------------------------------------------------------------- */
    arm_max_f32(testOutput, numStudents, &max_marks, &student_num);
    Serial.print("max = ");
    Serial.println(max_marks);

    /* ----------------------------------------------------------------------
    ** Call the Min function to calculate min marks among numStudents
    ** ------------------------------------------------------------------- */
    arm_min_f32(testOutput, numStudents, &min_marks, &student_num);
    Serial.print("min = ");
    Serial.println(min_marks);

    /* ----------------------------------------------------------------------
    ** Call the Mean function to calculate mean
    ** ------------------------------------------------------------------- */
    arm_mean_f32(testOutput, numStudents, &mean);
    Serial.print("mean = ");
    Serial.println(mean);

    /* ----------------------------------------------------------------------
    ** Call the std function to calculate standard deviation
    ** ------------------------------------------------------------------- */
    arm_std_f32(testOutput, numStudents, &_std);
    Serial.print("std = ");
    Serial.println(_std);

    /* ----------------------------------------------------------------------
    ** Call the var function to calculate variance
    ** ------------------------------------------------------------------- */
    arm_var_f32(testOutput, numStudents, &var);
    Serial.print("var = ");
    Serial.println(var);
    Serial.println();

    delay(1000 - (millis() % 1000));
    }

  2. Like
    monpetit reacted to Bingo600 in Free Book - Discovering.the.STM32.Microcontroller   
    Just saw this free book from Geoffrey Brown , a guy i have had some dialouge with, after i did the Versaloon port to the STM32-VL-Discovery board.
     
    Looks like he did a nice work here
     
    Discovering.the.STM32.Microcontroller-book
     
    Book Url
    ------------------
    www.cs.indiana.edu/~geobrown/book.pdf
     
     
     
    http://homes.soic.indiana.edu/geobrown/index.cgi/publications%C2'>
     
     
    /Bingo
  3. Like
    monpetit reacted to AlexanderSB in How to get malloc() to work?   
    Thank you monpetit!
     
    I solved my problem following these instructions:
    http://processors.wiki.ti.com/index.php/Stack_and_Heap_size_requirements
     
    But thank you for the help. 
  4. Like
    monpetit got a reaction from Automate in Energia Latest Releases   
    I am using Energia as a library like the libmaple with the Eclipse IDE. 
    The combination of libenergia, Eclipse (with Zylin Embedded debug plugin) and OpenOCD enables you to debug the LM4F120XL board.
    You can refer and modify my Stellaris build scripts to your taste. https://github.com/monpetit/libenergia
  5. Like
    monpetit got a reaction from bluehash in using CMSIS DSP library dsplib-cm4f.lib in Energia   
    You need the CMSIS DSP library compiled with gcc, that is "libarm_cortexM4lf_math.a".
    Then...
     
    1. make a directory for the CMSIS DSP libraries to include your energia programs. For example, 
       cd ~/Energia/libraries
       mkdir arm_math
     
    2. put the CMSIS DSP header files to library directory.
       header files: core_cm4.h, core_cm4_simd.h, core_cmFunc.h, core_cmInstr.h, arm_common_tables.h, arm_const_structs.h, arm_math.h
     
    3. put library file to suitable path.
       cp libarm_cortexM4lf_math.a  energia-0101E0009/hardware/tools/lm4f/arm-none-eabi/lib/thumb/armv7e-m/fpu/fpv4-sp-d16
     
    4. edit your ld script "dev/energia-0101E0009/hardware/lm4f/cores/lm4f/lm4fcpp.ld" to link math library. Append two line like this,
     


       /* Library configurations */
       GROUP(libgcc.a libc.a libm.a libarm_cortexM4lf_math.a)

     
    5. test your code.



    #ifndef __FPU_PRESENT
    #define __FPU_PRESENT 1
    #endif

    #include <arm_math.h>
    #include <arm_common_tables.h>
    #include <arm_const_structs.h>

    #define USE_STATIC_INIT

    /* ----------------------------------------------------------------------
    ** Global defines
    ** ------------------------------------------------------------------- */

    #define TEST_LENGTH_SAMPLES (20*4)

    /* ----------------------------------------------------------------------
    ** List of Marks scored by 20 students for 4 subjects
    ** ------------------------------------------------------------------- */
    const float32_t testMarks_f32[TEST_LENGTH_SAMPLES] =
    {
    42.000000, 37.000000, 81.000000, 28.000000,
    83.000000, 72.000000, 36.000000, 38.000000,
    32.000000, 51.000000, 63.000000, 64.000000,
    97.000000, 82.000000, 95.000000, 90.000000,
    66.000000, 51.000000, 54.000000, 42.000000,
    67.000000, 56.000000, 45.000000, 57.000000,
    67.000000, 69.000000, 35.000000, 52.000000,
    29.000000, 81.000000, 58.000000, 47.000000,
    38.000000, 76.000000, 100.000000, 29.000000,
    33.000000, 47.000000, 29.000000, 50.000000,
    34.000000, 41.000000, 61.000000, 46.000000,
    52.000000, 50.000000, 48.000000, 36.000000,
    47.000000, 55.000000, 44.000000, 40.000000,
    100.000000, 94.000000, 84.000000, 37.000000,
    32.000000, 71.000000, 47.000000, 77.000000,
    31.000000, 50.000000, 49.000000, 35.000000,
    63.000000, 67.000000, 40.000000, 31.000000,
    29.000000, 68.000000, 61.000000, 38.000000,
    31.000000, 28.000000, 28.000000, 76.000000,
    55.000000, 33.000000, 29.000000, 39.000000
    };


    /* ----------------------------------------------------------------------
    * Number of subjects X 1
    * ------------------------------------------------------------------- */
    const float32_t testUnity_f32[4] =
    {
    1.000, 1.000, 1.000, 1.000
    };


    /* ----------------------------------------------------------------------
    ** f32 Output buffer
    ** ------------------------------------------------------------------- */
    static float32_t testOutput[TEST_LENGTH_SAMPLES];


    /* ------------------------------------------------------------------
    * Global defines
    *------------------------------------------------------------------- */
    #define NUMSTUDENTS 20
    #define NUMSUBJECTS 4

    /* ------------------------------------------------------------------
    * Global variables
    *------------------------------------------------------------------- */

    uint32_t numStudents = 20;
    uint32_t numSubjects = 4;
    float32_t max_marks, min_marks, mean, _std, var;
    uint32_t student_num;

    /* ----------------------------------------------------------------------------------
    * Main f32 test function. It returns maximum marks secured and student number
    * ------------------------------------------------------------------------------- */

    void setup()
    {
    Serial.begin(9600);
    }

    void loop()
    {

    #ifndef USE_STATIC_INIT

    arm_matrix_instance_f32 srcA;
    arm_matrix_instance_f32 srcB;
    arm_matrix_instance_f32 dstC;

    /* Input and output matrices initializations */
    arm_mat_init_f32(&srcA, numStudents, numSubjects, (float32_t *)testMarks_f32);
    arm_mat_init_f32(&srcB, numSubjects, 1, (float32_t *)testUnity_f32);
    arm_mat_init_f32(&dstC, numStudents, 1, testOutput);

    #else

    /* Static Initializations of Input and output matrix sizes and array */
    arm_matrix_instance_f32 srcA = {
    NUMSTUDENTS, NUMSUBJECTS, (float32_t *)testMarks_f32
    };
    arm_matrix_instance_f32 srcB = {
    NUMSUBJECTS, 1, (float32_t *)testUnity_f32
    };
    arm_matrix_instance_f32 dstC = {
    NUMSTUDENTS, 1, testOutput
    };

    #endif


    /* ----------------------------------------------------------------------
    *Call the Matrix multiplication process function
    * ------------------------------------------------------------------- */
    arm_mat_mult_f32(&srcA, &srcB, &dstC);

    /* ----------------------------------------------------------------------
    ** Call the Max function to calculate max marks among numStudents
    ** ------------------------------------------------------------------- */
    arm_max_f32(testOutput, numStudents, &max_marks, &student_num);
    Serial.print("max = ");
    Serial.println(max_marks);

    /* ----------------------------------------------------------------------
    ** Call the Min function to calculate min marks among numStudents
    ** ------------------------------------------------------------------- */
    arm_min_f32(testOutput, numStudents, &min_marks, &student_num);
    Serial.print("min = ");
    Serial.println(min_marks);

    /* ----------------------------------------------------------------------
    ** Call the Mean function to calculate mean
    ** ------------------------------------------------------------------- */
    arm_mean_f32(testOutput, numStudents, &mean);
    Serial.print("mean = ");
    Serial.println(mean);

    /* ----------------------------------------------------------------------
    ** Call the std function to calculate standard deviation
    ** ------------------------------------------------------------------- */
    arm_std_f32(testOutput, numStudents, &_std);
    Serial.print("std = ");
    Serial.println(_std);

    /* ----------------------------------------------------------------------
    ** Call the var function to calculate variance
    ** ------------------------------------------------------------------- */
    arm_var_f32(testOutput, numStudents, &var);
    Serial.print("var = ");
    Serial.println(var);
    Serial.println();

    delay(1000 - (millis() % 1000));
    }

  6. Like
    monpetit got a reaction from vijay in using CMSIS DSP library dsplib-cm4f.lib in Energia   
    You need the CMSIS DSP library compiled with gcc, that is "libarm_cortexM4lf_math.a".
    Then...
     
    1. make a directory for the CMSIS DSP libraries to include your energia programs. For example, 
       cd ~/Energia/libraries
       mkdir arm_math
     
    2. put the CMSIS DSP header files to library directory.
       header files: core_cm4.h, core_cm4_simd.h, core_cmFunc.h, core_cmInstr.h, arm_common_tables.h, arm_const_structs.h, arm_math.h
     
    3. put library file to suitable path.
       cp libarm_cortexM4lf_math.a  energia-0101E0009/hardware/tools/lm4f/arm-none-eabi/lib/thumb/armv7e-m/fpu/fpv4-sp-d16
     
    4. edit your ld script "dev/energia-0101E0009/hardware/lm4f/cores/lm4f/lm4fcpp.ld" to link math library. Append two line like this,
     


       /* Library configurations */
       GROUP(libgcc.a libc.a libm.a libarm_cortexM4lf_math.a)

     
    5. test your code.



    #ifndef __FPU_PRESENT
    #define __FPU_PRESENT 1
    #endif

    #include <arm_math.h>
    #include <arm_common_tables.h>
    #include <arm_const_structs.h>

    #define USE_STATIC_INIT

    /* ----------------------------------------------------------------------
    ** Global defines
    ** ------------------------------------------------------------------- */

    #define TEST_LENGTH_SAMPLES (20*4)

    /* ----------------------------------------------------------------------
    ** List of Marks scored by 20 students for 4 subjects
    ** ------------------------------------------------------------------- */
    const float32_t testMarks_f32[TEST_LENGTH_SAMPLES] =
    {
    42.000000, 37.000000, 81.000000, 28.000000,
    83.000000, 72.000000, 36.000000, 38.000000,
    32.000000, 51.000000, 63.000000, 64.000000,
    97.000000, 82.000000, 95.000000, 90.000000,
    66.000000, 51.000000, 54.000000, 42.000000,
    67.000000, 56.000000, 45.000000, 57.000000,
    67.000000, 69.000000, 35.000000, 52.000000,
    29.000000, 81.000000, 58.000000, 47.000000,
    38.000000, 76.000000, 100.000000, 29.000000,
    33.000000, 47.000000, 29.000000, 50.000000,
    34.000000, 41.000000, 61.000000, 46.000000,
    52.000000, 50.000000, 48.000000, 36.000000,
    47.000000, 55.000000, 44.000000, 40.000000,
    100.000000, 94.000000, 84.000000, 37.000000,
    32.000000, 71.000000, 47.000000, 77.000000,
    31.000000, 50.000000, 49.000000, 35.000000,
    63.000000, 67.000000, 40.000000, 31.000000,
    29.000000, 68.000000, 61.000000, 38.000000,
    31.000000, 28.000000, 28.000000, 76.000000,
    55.000000, 33.000000, 29.000000, 39.000000
    };


    /* ----------------------------------------------------------------------
    * Number of subjects X 1
    * ------------------------------------------------------------------- */
    const float32_t testUnity_f32[4] =
    {
    1.000, 1.000, 1.000, 1.000
    };


    /* ----------------------------------------------------------------------
    ** f32 Output buffer
    ** ------------------------------------------------------------------- */
    static float32_t testOutput[TEST_LENGTH_SAMPLES];


    /* ------------------------------------------------------------------
    * Global defines
    *------------------------------------------------------------------- */
    #define NUMSTUDENTS 20
    #define NUMSUBJECTS 4

    /* ------------------------------------------------------------------
    * Global variables
    *------------------------------------------------------------------- */

    uint32_t numStudents = 20;
    uint32_t numSubjects = 4;
    float32_t max_marks, min_marks, mean, _std, var;
    uint32_t student_num;

    /* ----------------------------------------------------------------------------------
    * Main f32 test function. It returns maximum marks secured and student number
    * ------------------------------------------------------------------------------- */

    void setup()
    {
    Serial.begin(9600);
    }

    void loop()
    {

    #ifndef USE_STATIC_INIT

    arm_matrix_instance_f32 srcA;
    arm_matrix_instance_f32 srcB;
    arm_matrix_instance_f32 dstC;

    /* Input and output matrices initializations */
    arm_mat_init_f32(&srcA, numStudents, numSubjects, (float32_t *)testMarks_f32);
    arm_mat_init_f32(&srcB, numSubjects, 1, (float32_t *)testUnity_f32);
    arm_mat_init_f32(&dstC, numStudents, 1, testOutput);

    #else

    /* Static Initializations of Input and output matrix sizes and array */
    arm_matrix_instance_f32 srcA = {
    NUMSTUDENTS, NUMSUBJECTS, (float32_t *)testMarks_f32
    };
    arm_matrix_instance_f32 srcB = {
    NUMSUBJECTS, 1, (float32_t *)testUnity_f32
    };
    arm_matrix_instance_f32 dstC = {
    NUMSTUDENTS, 1, testOutput
    };

    #endif


    /* ----------------------------------------------------------------------
    *Call the Matrix multiplication process function
    * ------------------------------------------------------------------- */
    arm_mat_mult_f32(&srcA, &srcB, &dstC);

    /* ----------------------------------------------------------------------
    ** Call the Max function to calculate max marks among numStudents
    ** ------------------------------------------------------------------- */
    arm_max_f32(testOutput, numStudents, &max_marks, &student_num);
    Serial.print("max = ");
    Serial.println(max_marks);

    /* ----------------------------------------------------------------------
    ** Call the Min function to calculate min marks among numStudents
    ** ------------------------------------------------------------------- */
    arm_min_f32(testOutput, numStudents, &min_marks, &student_num);
    Serial.print("min = ");
    Serial.println(min_marks);

    /* ----------------------------------------------------------------------
    ** Call the Mean function to calculate mean
    ** ------------------------------------------------------------------- */
    arm_mean_f32(testOutput, numStudents, &mean);
    Serial.print("mean = ");
    Serial.println(mean);

    /* ----------------------------------------------------------------------
    ** Call the std function to calculate standard deviation
    ** ------------------------------------------------------------------- */
    arm_std_f32(testOutput, numStudents, &_std);
    Serial.print("std = ");
    Serial.println(_std);

    /* ----------------------------------------------------------------------
    ** Call the var function to calculate variance
    ** ------------------------------------------------------------------- */
    arm_var_f32(testOutput, numStudents, &var);
    Serial.print("var = ");
    Serial.println(var);
    Serial.println();

    delay(1000 - (millis() % 1000));
    }

×
×
  • Create New...