# PIC18F4550 problem. Stepper motor not rotating

Status
Not open for further replies.

#### burpal

##### Newbie level 1
hello all, i wrote a code for rotating a stepper motor. The code seems to work fine as i connected 4 LED's to test the stepping sequence.

I am using the ULN 2003 to drive the stepper motor(M35SP). When i switch on the power source(24V), my microcontroller stops the stepping sequence and gets stuck at the first value, in my program, 0x01...

Here is the source code i am using...

Code:
#include<p18cxxx.h>
#include <delays.h>
void main()
{
TRISA=0x00;
PORTA=0x00;
while(1)
{
PORTA=0x01;
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
PORTA=0x02;
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
PORTA=0x04;
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
PORTA=0x08;
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
Delay1KTCYx(240);
}
}

#### elrayes

##### Full Member level 5
try to re-build the delay functions in C18 with your project, sometimes we need to rebuild functions.
i noticed in another post someone mentioned the LATA register, initiate the LATx register with a value.

I have a doubt in your utilisation of the ULN.