Autor Tema: Problema en mplab  (Leído 1888 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado massi

  • PIC10
  • *
  • Mensajes: 6
Problema en mplab
« en: 08 de Enero de 2018, 00:56:39 »
Hola alguien podría ayudarme con estos errores.
Tengo instalado el plugin ccs.

Código:

#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 //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)

Desconectado KILLERJC

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8242
Re:Problema en mplab
« Respuesta #1 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
  1. #include <16F628A.h>
  2.  
  3. #FUSES NOWDT
  4. #FUSES INTRC_IO
  5. #FUSES NOPUT
  6. #FUSES NOPROTECT
  7. #FUSES NOBROWNOUT
  8. #FUSES NOMCLR
  9. #FUSES NOLVP
  10. #FUSES NOCPD
  11.  
  12. #use delay(clock=4000000)
  13. #define led1 PIN_A1
  14. #define led2 PIN_A2
  15.  
  16. void main()
  17. {
  18.   int i;
  19.   while (1)
  20.   {
  21.      for (i = 0;i < 3; i++ ){
  22.           output_high(led1);
  23.           output_high(led2);
  24.           delay_ms(1000);
  25.           output_low(led1);
  26.           output_low(led2);
  27.           delay_ms(700);
  28.      }
  29.    }
  30. }

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.

Desconectado massi

  • PIC10
  • *
  • Mensajes: 6
Re:Problema en mplab
« Respuesta #2 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


 

anything