Problem in arduino UNO while controlling BLDC motor

I am making project where I have used all the 12 pins of arduino (from 2 to 13). It is done to run a bldc motor which has three hall sensor that provide +5 or 0 V depending on rotor position. The hall sensor`s signals are input to arduino.
The following short description is given here to indicate the pin no. used in this program.

int Y = 3; // Q1_Output which goes to the gate driver circuit of a three phase inverter
int J = 5; // Q2_Output to the gate driver circuit of a three phase inverter
int Z = 6; // Q3_Output to the gate driver circuit of a three phase inverter
int I = 9; // Q4_Output to the gate driver circuit of a three phase inverter
int X = 10; // Q5_Output to the gate driver circuit of a three phase inverter
int Q = 11; //Q6_Output to the gate driver circuit of a three phase inverter

int C = 7; // H1_Input from motor hall sensor
int A = 8; // H2_Input from motor hall sensor
int B = 12; // H3_Input from motor hall sensor
int S = 2; // PWMm_Input from an electronic circuit which gives +5 V and 0 v
int D = 4; // PWMr_Input from an electronic circuit which gives +5 V and 0 v
int E = 13; //C_Input from a 5 V source which is given from another microcontroller and a pull down resistor (6k) is used TO this pin as well.

The problem i faced is very different. The motor runs for a 1 to 2 minutes and then all the outputs pins of the arduino either goes LOW or HIGH which causes motor shut down. If I press reset button again then it works for some moments nicely then again it goes.

So, what is the problem ?? Can anyone help me?

So, what is the problem ?

There's something wrong with your wiring or your software.
Or both.

"I have used all the 12 pins of arduino (from 2 to 13)."
You still have 14 to 19 left as well (aka A0 to A5).

As AWOL indicates, not enough info provided. Post all your code, a schematic, the motor types used, and the power source for the motor.

Dear,

I am using the digital pins 2 to 13. Sorry for the short post but I have some problem to share all code as I need permission from my supervisor.

The source used here for the motor is 48 V battery which is used in electric vehicle. If you require more then I can send it via email. I have some doubt about using of pin 13.

Power of the motor 500 W and voltage 48 V.

If anybody can find the solution, please respond asap.