You might want to post the schematic, or code. Are you using fly back diodes for your inductive loads?