+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Full Member level 1
    Points: 1,231, Level: 7
    yzou_ua's Avatar
    Join Date
    Nov 2008
    Posts
    95
    Helped
    1 / 1
    Points
    1,231
    Level
    7

    How to test a written c code??

    I just completed a c code for a dsp controlled motor drive.
    What I to do next to test this code before apply it onto hardware??
    Any suggestions?

    •   AltAdvertisement

        
       

  2. #2
    Full Member level 1
    Points: 2,053, Level: 10
    Achievements:
    7 years registered

    Join Date
    Dec 2008
    Location
    Bangladesh
    Posts
    111
    Helped
    21 / 21
    Points
    2,053
    Level
    10

    How to test a written c code??

    You can use simulation Software.



    •   AltAdvertisement

        
       

  3. #3
    Full Member level 4
    Points: 2,211, Level: 10

    Join Date
    Apr 2009
    Location
    Hyderabad, India
    Posts
    217
    Helped
    5 / 5
    Points
    2,211
    Level
    10

    Re: How to test a written c code??

    Simulation is the best option but if u want to check on line whether code is working or not use Debugger for that.
    It will be helpful to check on line.

    Regards
    Chanchal



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 1
    Points: 8,577, Level: 22
    klug's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Helped
    13 / 13
    Points
    8,577
    Level
    22

    Re: How to test a written c code??

    There is MIRSA C standart, created to avoid possible errors in C code, that consists of 126 rules.

    http://en.wikipedia.org/wiki/MISRA_C

    Some programmer's tools are making check for MISRA C complaince. For example "Development Assistant for C".

    It is not so good idea to reformat your ready code, but in the future you can use it from the start to make your code more reliable.



  5. #5
    Member level 2
    Points: 741, Level: 5

    Join Date
    Jun 2010
    Location
    India
    Posts
    47
    Helped
    3 / 3
    Points
    741
    Level
    5

    Re: How to test a written c code??

    Use a Debugger which is specific to ur IDE.. it helps a lot in debugging



  6. #6
    Member level 2
    Points: 1,242, Level: 7

    Join Date
    Jul 2007
    Posts
    42
    Helped
    3 / 3
    Points
    1,242
    Level
    7

    How to test a written c code??

    I would say first start with unit test. First see if it working as you have expected. Check CUnit for this.



    •   AltAdvertisement

        
       

  7. #7
    Advanced Member level 4
    Points: 9,782, Level: 23

    Join Date
    Aug 2004
    Location
    Egypt
    Posts
    1,185
    Helped
    145 / 145
    Points
    9,782
    Level
    23

    Re: How to test a written c code??

    build a test case with proper stubs and run ur code accordingly.
    --
    Amr



  8. #8
    Advanced Member level 3
    Points: 6,429, Level: 19
    Achievements:
    7 years registered

    Join Date
    Jun 2007
    Posts
    821
    Helped
    220 / 220
    Points
    6,429
    Level
    19

    Re: How to test a written c code??

    Most probably build a simple hardware to test. Hardware tends to give unexpected weird behaviours. Such as switch where we cant simulate debouncing. Everything seems ok on simulation but harewire on hardware



--[[ ]]--