#use delay(clock=4000000) #define led1 PIN_A1 //Pino ao qual o led esta ligado #define led2 PIN_A2
void main() { while (1) { for (int i = 0;i < 3; i++ ){ output_bit(led1, TRUE); output_bit(led2, TRUE); delay_ms(1000); output_bit(led1, FALSE); output_bit(led2, FALSE) delay_ms(700); } } }
Errores:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf make[1]: Entering directory 'C:/Users/pc/MPLABXProjects/proyecto1.X' make -f nbproject/Makefile-default.mk dist/default/production/proyecto1.X.production.hex make[2]: Entering directory 'C:/Users/pc/MPLABXProjects/proyecto1.X' gnumkdir -p build/default/production gnumkdir -p dist/default/production "C:\PROGRA~1\PICC\CCSCON.exe" out="build/default/production" newfile1.c +FM +DF +CC +Y=9 +EA +DF +LN +T +A +M +J +EA +Z -P #__16F628A=1 C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:18:1: Warning#203 Condition always TRUE C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:26:9: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:30:14: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:30:31: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:40:14: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:40:32: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:50:15: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:50:33: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:63:14: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:63:32: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:73:14: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:73:32: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:83:14: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:83:32: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:93:14: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:93:31: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:103:14: Error#31 Identifier is already used in this scope C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:103:32: Error#76 Expect ; C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:20:14: Info#300 More info: First Declaration of i make[2]: *** [build/default/production/newfile1.o] Error 1 C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:113:14: Error#31 Identifier is already used in this scope make[1]: *** [.build-conf] Error 2 C:\Users\pc\MPLABXProjects\proyecto1.X\newfile1.c:113:31: Error#76 Expect ; make: *** [.build-impl] Error 2 19 Errors, 1 Warnings. Build Failed. nbproject/Makefile-default.mk:111: recipe for target 'build/default/production/newfile1.o' failed make[2]: Leaving directory 'C:/Users/pc/MPLABXProjects/proyecto1.X' nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed make[1]: Leaving directory 'C:/Users/pc/MPLABXProjects/proyecto1.X' nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
BUILD FAILED (exit value 2, total time: 15s)
Título: Re:Problema en mplab
Publicado por: KILLERJC en 08 de Enero de 2018, 12:35:52
Hay un par de cosas que veo que debes cambiar, errores, y algunas cosas que no les gusta a los compiladores.
Código: C
#include <16F628A.h>
#FUSES NOWDT
#FUSES INTRC_IO
#FUSES NOPUT
#FUSES NOPROTECT
#FUSES NOBROWNOUT
#FUSES NOMCLR
#FUSES NOLVP
#FUSES NOCPD
#use delay(clock=4000000)
#define led1 PIN_A1
#define led2 PIN_A2
void main()
{
int i;
while(1)
{
for(i =0;i <3; i++){
output_high(led1);
output_high(led2);
delay_ms(1000);
output_low(led1);
output_low(led2);
delay_ms(700);
}
}
}
Proba asi, las cosas que cambie fueron:
- Cambie los output_bit por output_low/high sin ninguna razón.. pienso que es mas legible. - el int i, lo saque afuera, a algunos compiladores no les gusta que se declaren dentro del for, por eso mismo lo saque afuera. - había uno de los output_bit que le faltaba el punto y coma, uno de los últimos, se lo agregue
Lamentablemente no poseo tiempo disponible como para probarlo, asi que te lo dejo a vos a eso.
Título: Re:Problema en mplab
Publicado por: massi en 08 de Enero de 2018, 18:36:39
El código en verdad es más largo y con más de un for dentro del while y definia in i dentro de cada for. Lo solucione definiendo int i una sola vez en el while. Gracias por la ayuda