How to test a written c code??

Status
Not open for further replies.

yzou_ua

Member level 5
Joined
Nov 5, 2008
Messages
92
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,869
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?
 

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
 

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

https://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.
 

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

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

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

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
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…