I made this program to run a stepper motor by uC PIC18f4520.
I need you to find a mistake in this program:
#include <hitech.h>
#include <pic18.h>
void DELAY(void); /*Spend time function*/
int sequence[8] = {0xc, 0x4, 0x6, 0x2, 0x3, 0x1, 0x9, 0x8}; /* running sequence for motor (half step)*/
int N; /*number of sequence*/
main()
{
TRISC=0xff;
TRISD=0x00;
N=0;
while((PORTC&0x2)==0x2)
{
for(;((PORTC&0x1)==0x1);N++)
{
PORTD = sequence[N];
DELAY();
if(N=8)
{
N=0;
}
}
for(;((PORTC&0x1)==0x0);N--)
{
PORTD = sequence[N];
DELAY();
if(N=0)
{
N=8;
}
}
}
}
void DELAY(void)
{
unsigned int i;
for(i=0;i<0x7fff;i++);
}
if you find any thing wrong type it.
thanks.
I need you to find a mistake in this program:
#include <hitech.h>
#include <pic18.h>
void DELAY(void); /*Spend time function*/
int sequence[8] = {0xc, 0x4, 0x6, 0x2, 0x3, 0x1, 0x9, 0x8}; /* running sequence for motor (half step)*/
int N; /*number of sequence*/
main()
{
TRISC=0xff;
TRISD=0x00;
N=0;
while((PORTC&0x2)==0x2)
{
for(;((PORTC&0x1)==0x1);N++)
{
PORTD = sequence[N];
DELAY();
if(N=8)
{
N=0;
}
}
for(;((PORTC&0x1)==0x0);N--)
{
PORTD = sequence[N];
DELAY();
if(N=0)
{
N=8;
}
}
}
}
void DELAY(void)
{
unsigned int i;
for(i=0;i<0x7fff;i++);
}
if you find any thing wrong type it.
thanks.