Waran
Newbie level 5
I wanted to know whats wrong with my coding...I wanted to just logic high extra 2 pins which are port B5 and port B6. I put the coding as below. I could compile the coding but when I burn the coding into my PIC18f452, it shows error....Can I know whats wrong with the technique I use?
#include <18f452.h>
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay (clock=20000000)
#define m1 pin_C0
#define m2 pin_C1
#define m3 pin_C2
#define m4 pin_C3
#define dir pin_D1
#define brake pin_D0
#define supply pin_B5
#define supply2 pin_B6
#define button1 pin_D2
#define button2 pin_D3
#define button3 pin_D4
#define button4 pin_D5
#define button5 pin_D6
#define button6 pin_B0
#define button7 pin_B1
#define button8 pin_B2
#define buttonstop pin_B4
#define on 0
#define off 1
void main (void)
{
output_high(supply); // This part which confuse me. Without this part, I could
output_high(supply2); // burn it and run the program.
loop:
if(input(button1) == on && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8)== off && input(buttonstop)== off )
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == on && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
output_low(m1);
output_low(m2);
output_low(m3);
output_low(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == on && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== on && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == on && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == on && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == on && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == on && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == on && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == on && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == on && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== on && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == on && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == on && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == on && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == on && input(buttonstop) == on )
{
output_high(brake);
}
goto loop;
}
#include <18f452.h>
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay (clock=20000000)
#define m1 pin_C0
#define m2 pin_C1
#define m3 pin_C2
#define m4 pin_C3
#define dir pin_D1
#define brake pin_D0
#define supply pin_B5
#define supply2 pin_B6
#define button1 pin_D2
#define button2 pin_D3
#define button3 pin_D4
#define button4 pin_D5
#define button5 pin_D6
#define button6 pin_B0
#define button7 pin_B1
#define button8 pin_B2
#define buttonstop pin_B4
#define on 0
#define off 1
void main (void)
{
output_high(supply); // This part which confuse me. Without this part, I could
output_high(supply2); // burn it and run the program.
loop:
if(input(button1) == on && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8)== off && input(buttonstop)== off )
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == on && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
output_low(m1);
output_low(m2);
output_low(m3);
output_low(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == on && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== on && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_high(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == on && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == on && input(button7) == off && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_high(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == on && input(button8) == off && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_high(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == on && input(buttonstop)== off)
{
delay_ms(1000);
delay_ms(1000);
output_low(m1);
output_low(m2);
output_high(m3);
output_high(m4);
output_low(dir);
output_low(brake);
}
else if(input(button1) == on && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == on && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == on && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== on && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == on && input(button6) == off && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == on && input(button7) == off && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == on && input(button8) == off && input(buttonstop) == on )
{
output_high(brake);
}
else if(input(button1) == off && input(button2) == off && input(button3) == off && input(button4)== off && input(button5) == off && input(button6) == off && input(button7) == off && input(button8) == on && input(buttonstop) == on )
{
output_high(brake);
}
goto loop;
}