Hi,
I'm new in microcontroller programming. I am using PIC16F877A for rotating bipolar stepper motor & controlling. I have done one code using embeded C on MPLAB. I see that my code is working good. I also use Proteus Professional to see the output.
The code is -
Here, i use 2 input and 4 output. To see the 4 output use 4 LED.
When input(PIN_A1) is ON then LED's are ON sequentially and when input(PIN_A2) is ON then the all LED's are OFF. It's ok.
But again, when input(PIN_A1) is ON then LED's are ON sequentially from the beginning. It is my problem. I want to pause the program and starts again from the present states.
I'm new in this sector that's why can't understand how can i control this. Please someone help me ......
I'm new in microcontroller programming. I am using PIC16F877A for rotating bipolar stepper motor & controlling. I have done one code using embeded C on MPLAB. I see that my code is working good. I also use Proteus Professional to see the output.
The code is -
Rich (BB code):
*******************************************************
#include<16F877A.h>
#fuses HS,NOWDT
#use delay(clock=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
void main()
{
while(true){
set_tris_a(0x06);
set_tris_b(0x00);
output_b(0x00);
if(input(PIN_A1) == 0){
int i;
for(i=0; i<6; i++)
{
output_b(0x01); //1 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
output_b(0x02); //2 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
output_b(0x04); //3 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
output_b(0x08); //4 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
}
for(i=0; i<6; i++)
{
output_b(0x04); //3 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
output_b(0x02); //2 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
output_b(0x01); //1 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
output_b(0x08); //4 No. PIN
delay_ms(500);
output_b(0x00);
if(input(PIN_A2) == 0){
goto stop;
}
}
stop: continue;
} //end if
} //end while
} //end main
*******************************************************
When input(PIN_A1) is ON then LED's are ON sequentially and when input(PIN_A2) is ON then the all LED's are OFF. It's ok.
But again, when input(PIN_A1) is ON then LED's are ON sequentially from the beginning. It is my problem. I want to pause the program and starts again from the present states.
I'm new in this sector that's why can't understand how can i control this. Please someone help me ......
Attachments
-
70.6 KB Views: 453
Last edited by a moderator: