Errores compilador XC8

Buenos días amiguitos del foro, tenía mucho tiempo sin escribir por aquí y es que tenía de lado los proyectos de electrónica por circunstancias un poco mas delicadas pero por aquí estamos de nuevo. El caso es que vuelvo a retomar mi aprendizaje de programación de microcontroladores, en éste caso decidí aprender lo que sería lenguaje C mas específicamente Xc8 en el mMplabx.
Me he guiado por vídeo tutoriales básicamente y todo ha salido bien, mis programas compilan sin problema pero llegué al momento de programar el timer0 y me da un problema al compilar en la interrupción, decidí dejarlo tal cual lo tiene la persona del vídeo que vi y sigue sin compilar le he hecho de todo desde borrar el programa y el proyecto y volverlo a crear hasta reescribirlo y no termina de correr, quizá hay algún problema sencillo pero no termino de verlo por eso recurro a ustedes que se que siempre están dispuestos a ayudar, puede que sea un problema de librería pero no se como resolverlo, como dato extra puedo decir que en la inclusión de <xc.h> me pone un bombillito de alerta, les dejo el código:

#include <xc.h>
#include <stdio.h>
#include <pic18f4550.h>

// PIC18F4550 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1L
#pragma config PLLDIV = 1 // PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
#pragma config USBDIV = 1 // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)

// CONFIG1H
#pragma config FOSC = INTOSC_HS // Oscillator Selection bits (Internal oscillator, HS oscillator used by USB (INTHS))
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

// CONFIG2L
#pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = ON // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 3 // Brown-out Reset Voltage bits (Minimum setting 2.05V)
#pragma config VREGEN = OFF // USB Voltage Regulator Enable bit (USB voltage regulator disabled)

// CONFIG2H
#pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)

// CONFIG3H
#pragma config CCP2MX = ON // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = ON // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config LPT1OSC = OFF // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)

// CONFIG4L
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = ON // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config ICPRT = OFF // Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
#pragma config CP2 = OFF // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
#pragma config CP3 = OFF // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)

// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
#pragma config WRT2 = OFF // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
#pragma config WRT3 = OFF // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)

// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

#define XTAL_FREQ 8000000

void interrupt TIEMPO (void){

INTCONbits.GIE=0;
if (INTCONbits.T0IE && INTCONbits.T0IF){

PORTD=PORTD+1;
INTCONbits.T0IF=0;
TMR0= 3036;
}

}

void main(void) {

OSCCON= 0b01100010;
TRISD=0;
ei();
INTCON= 0b10100000;
T0CON= 10000100;
TMR0= 3036;

while(1){

}

}
************************************************************************************************************************************************************************************
Y éste es el error que arroja Mplabx

pruebas.c:92:6: error: variable has incomplete type 'void'
void interrupt TIEMPO (void){
^
pruebas.c:92:15: error: expected ';' after top level declarator
void interrupt TIEMPO (void){
^
;
2 errors generated.

********************************************************************************************************************************************************************************

De antemano muchas gracias muchachos, si necesitan algún otro detalle háganmelo saber.
Otro detalle que se me pasaba es que si quito la palabra tiempo en void interrupt TIEMPO (void){ el programa compila pero no funciona y cuando intento hacer el debug no me deja poner el breakline dentro de esa subrutina por eso no puedo ver donde esta el error.
 
Por el primer error indica que tenes variables sin indicar el tipo
El segundo es un error de sintaxis luego de ";" o esta faltando

Asi es muy dificil de ver tu código porque no utilizas las posibilidades del editor, justo a la derecha de las caritas, insertar, luego código luego el lenguaje y listo
 
gracias pandacba no sabia como era ya lo agrego de esa manera. lo otro es que todos los tipos de variables están especificados según creo yo.
C:
#include <stdio.h>
#include <pic18f4550.h>




// PIC18F4550 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1L
#pragma config PLLDIV = 1       // PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
#pragma config USBDIV = 1       // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)

// CONFIG1H
#pragma config FOSC = INTOSC_HS // Oscillator Selection bits (Internal oscillator, HS oscillator used by USB (INTHS))
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

// CONFIG2L
#pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = ON         // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 3         // Brown-out Reset Voltage bits (Minimum setting 2.05V)
#pragma config VREGEN = OFF     // USB Voltage Regulator Enable bit (USB voltage regulator disabled)

// CONFIG2H
#pragma config WDT = OFF        // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
#pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)

// CONFIG3H
#pragma config CCP2MX = ON      // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = ON      // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config LPT1OSC = OFF    // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)

// CONFIG4L
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = ON         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config ICPRT = OFF      // Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)
#pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

// CONFIG5L
#pragma config CP0 = OFF        // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
#pragma config CP1 = OFF        // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
#pragma config CP2 = OFF        // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
#pragma config CP3 = OFF        // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)

// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
#pragma config WRT1 = OFF       // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
#pragma config WRT2 = OFF       // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
#pragma config WRT3 = OFF       // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)

// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF      // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>




#define XTAL_FREQ 8000000



void interrupt  TIEMPO (void){

INTCONbits.GIE=0;
        if (INTCONbits.T0IE && INTCONbits.T0IF){
           
            PORTD=PORTD+1;
            INTCONbits.T0IF=0;
             TMR0= 3036;
        }
   
}




void main(void) {
   
    OSCCON= 0b01100010;
    TRISD=0;
    ei();
     INTCON= 0b10100000;
     T0CON= 10000100;
     TMR0= 3036;
   
   
            while(1){
               
               
               
               
               
            }
               

}
 
Otro detalle que se me pasaba es que si quito la palabra tiempo en
void interrupt TIEMPO (void){ el programa compila pero no funciona y cuando intento hacer el debug no me deja poner el breakline dentro de esa subrutina por eso no puedo ver donde esta el error..
Tenes un problema con la declaración de la función de interrupción, así que adentro de ella no vas a encontrar nada que te ayude. Leé el manual del XC8 para ver como se declaran las rutinas de interrupción y como se mapean al vector correspondiente.
Acá está: http://ww1.microchip.com/downloads/en/devicedoc/50002053g.pdf
Y el primer error es el prototipo del main, que debe ser:
C:
int main( void ) {
    ....
}
Aunque dice que los compiladores de 8 bits usan void en vez de int... a saber cuales compiladores...mejor leelo vos.

En cuanto a las interrupciones, el manual es claro y tenés declarada cualquier verdura. Se hace algo como lo que sigue (tomado del manual del XC8):
C:
__interrupt (low_priority) void getData(void) {
    if (TMR0IE && TMR0IF) {
        TMR0IF=0;
        ++tick_count;
    }
}
 
Última edición:
hola zoidberg gracias por responder.. mira te cuento que lei parte del manual cuando empece con el problema pero las soluciones ahí dadas no me parecieron que me ayudaran.. por ejemplo lo de la prioridad de la interrupción, incluso lo probé pero muy superficialmente.. igual voy a leerlo y tratar de solucionar con eso, solo que bueno llevara su tiempo y lo que no quiero es que el tema se enfrie , pero tratare de hacerlo lo mas rapido posible.. voy a probar con la declaración en int primero a ver y les cuento.
lo otro es lo raro del caso porque el vídeo del cual me guió en youtube hace la interrupción de esa manera.. entonces no se a que se deba tal diferencia. si tienen alguna idea de porque es así díganmela porfa..
les dejo igual el link del tutorial por si quieren echar un ojo ustedes mismos..
gracias nuevamente por la ayuda.. les escribo en lo que pruebe con los cambios..
saludos..

 
Buenas tardes tardes compis; tengo un problemas que no puedo resolver y a ver si alguien me puede ayudar.
Estoy haciendo una secuencia de luces policia para un coche RC. Las secuencias son unas 5 distintas y cada una de ellas se repite unas 6 veces y luego empieza el bucle de nuevo. Cuando intento ponerlo en codigo HEX me pone esto:
using updated 32-bit floating-point libraries; improved accuracy might increase code size.
*0: (1347) can't find 0x408 words (0x408 withtotal) for psect "maintext" in class "CODE" (largest unused contiguous range 0x3EC).
*updated 32-bit floating-point routines might trigger "can't find space" messages appearing after updating to this release; consider using the smaller 24-bit floating-point types.
*Error returned from [xc8.exe]

No entiendo ni "papa" de ingles, lo único que entiendo es que me dice que considere bajar de 24 bit. De heccho en las repeticiones de las secuencias, si le quito a las secuencias alguna repeticion y el archivo pesa unos 22 kb si que me deja crear el codigo HEX. Habría alguna forma de modificar algo en el programa para poder meter todas las secuencias y repeticiones que yo quisiera?
Por cierto el programa que utilizo es el flowcode8 y el PIC el 16F84A. Gracias por echarme una mano.
 
DOSMETROS, ahi lo he mandado creo.....
Gudino Roberto duberlin, si te soy sincero no se donde puedo mirar el codigo fuente, soy muy novato en esto.
Vuelvo a crear todo de nuevo y llega un momento en que no me deja crear el codigo HEX.
 

Adjuntos

  • LUCES POLICIA.zip
    44.1 KB · Visitas: 5
El mensaje de error dice que te has quedado sin memoria. El chip tiene 1024 words, pero tu programa tiene 1032 words. Debes acortarlo.

La forma más sencilla es creando bucles for().

Por ejemplo, al principio de las secuencias, repites tres veces estas líneas:
C:
        // Name: Output, Type: Output: 0 -> PORTB
        SET_PORT(B,(0));

        // Name: Delay, Type: Delay: 100 ms
        FCI_DELAYBYTE_MS(100);

        // Name: Output, Type: Output: 1 -> B0
        SET_PORT_PIN(B,0,(1));

        // Name: Output, Type: Output: 1 -> B1
        SET_PORT_PIN(B,1,(1));

        // Name: Output, Type: Output: 1 -> B2
        SET_PORT_PIN(B,2,(1));

        // Name: Output, Type: Output: 1 -> B3
        SET_PORT_PIN(B,3,(1));

        // Name: Delay, Type: Delay: 100 ms
        FCI_DELAYBYTE_MS(100);
Bueno, pues si eso lo metes en un bucle for (i=0; i < 3; i++) { ... } pues te ahorras unos cuantos bytes...

Además, no veo por qué razón intenta meter bibliotecas de punto flotante. No veo en tu código nada que necesite hacer cálculos con punto flotante. Si puedes ir a las opciones de compilación e indicar que no quieres que las incluya, mejor.
 
Sí, esas instrucciones no son de XC8, en XC8 con escribir RB1 = 1; ya se escribe un 1 en el bit 1 del puerto B.
La instrucción nativa de retardo en XC8 es: __delay_ms(X);
Y sí se están incluyendo librerías de FlowCode, como esta:
#include "C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c"
También se ha incluido la librería math.h que dudo que tenga uso.
Si ese código estuviera escrito con las instrucciones de XC8 estaría más reducido.
Tanto, que hasta pienso que se estaría ahorrando más de un 80% de memoria.
 
Perdonar por no contestar antes, es que he tenido lio con los peques en casa; De todas maneras seguire investigando porque por lo que veo me queda muuuucho por aprender, el lenguaje en la electronica no lo manejo muy bien, y meterme en programas como PCW para yo generar el codigo HEX para mi es complicado, me manejo mejor en programas con figuras y como dice Dr. Zoidberg que el programa lo genere solo; lo que pasa que por lo que veo el archivo que genera el Flowcode8 es muy grande para el 16f84a. He intentado hacerlo con me ha dicho joaquinferrero, pero joder, me hago cada lio, que es para echarse a llorar, empiezo a quitar macros y demas cosas que creo que no valen y me da error siempre, pero bueno, a ver si con paciencia puedo ir haciendolo poco a poco; como referencia cojo otro Hex que tengo copiados de otros sitios, pero ni aun asi, yo creo que o debo comprender muy muy bien todas las palabras y siglas para iniciar un proyecto o comprarme otro pic que soporte mas bits como el 16f648a que por lo que he podido ver hasta ahora tienen muchisima más capacidad que el 16f84a, pero de momento toca estudiar a ver como puedo bajar los bits. De todas maneras os agradezco muchisimo el interes ya soy un viejales y ya no se suele encontrar personas con un poco de paciencia.
 
Buenas tardes; por fin he conseguido controlar casi casi del todo el tema. Me he quedado atascado aqui, no se porque razón me da error en la linea 123, por más que le doy vueltas no logro encontrar la razón o motivo, a ver si alquien me puede echar un cable, grazie
 

Adjuntos

  • LUCES PRUEBA.zip
    2.3 KB · Visitas: 2
Atrás
Arriba