Autor Tema: Delay10TCY() No me funciona en XC8  (Leído 2092 veces)

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

Desconectado Limbo

  • PIC10
  • *
  • Mensajes: 44
Delay10TCY() No me funciona en XC8
« en: 20 de Junio de 2013, 11:58:18 »
Hola buenas,

Tengo este simple codigo:
Código: [Seleccionar]
// FUNCION PRINCIPAL
#include <xc.h>
#include <delays.h>
#define _XTAL_FREQ 4000000
// PIC16F819 Configuration Bit Settingsbvdfg
// PIC16F648A Configuration Bit Settings
#define config INTOSC = ON // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)

#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF     // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF      // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
#pragma config BOREN = ON       // Brown-out Detect Enable bit (BOD enabled)
#pragma config LVP = OFF        // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF




void main(void)
{
    int i;
     //config
    ANSELH=0;
    ANSEL=0;
    TRISA=0xFF;
    TRISB=0x0;
Delay10TCY(20);
    PORTB=0x0;
    for(;;){
        if(RA0 == 1){
            PORTB=0x0;
        }else{
            PORTB=1;
            for(i=0;i<=4;i++){
                PORTB=PORTB<<1;
                __delay_ms(1000);
           
            }
        }
    }



}


Y meda este error:
Código: [Seleccionar]
:: warning: Omniscient Code Generation not available in Free mode
:0: error: undefined symbol:
        _Delay10TCY(dist/default/production\tuto_C18.X.production.obj)
(908) exit status = 1
make[2]: *** [dist/default/production/tuto_C18.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `C:/Users/Limbo/MPLABXProjects/tuto_C18.X'
make[1]: Leaving directory `C:/Users/Limbo/MPLABXProjects/tuto_C18.X'

BUILD FAILED (exit value 2, total time: 5s)

Me tiene loco, estoy usando _delay y __delay_ms, pero quiero saber porque falla eso... :5]
Gracias.
Saludos.

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Delay10TCY() No me funciona en XC8
« Respuesta #1 en: 20 de Junio de 2013, 15:06:18 »
Hola buenas,

Tengo este simple codigo:
Código: [Seleccionar]
// FUNCION PRINCIPAL
#include <xc.h>
#include <delays.h>
#define _XTAL_FREQ 4000000
// PIC16F819 Configuration Bit Settingsbvdfg
// PIC16F648A Configuration Bit Settings
#define config INTOSC = ON // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)

#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF     // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF      // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
#pragma config BOREN = ON       // Brown-out Detect Enable bit (BOD enabled)
#pragma config LVP = OFF        // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF




void main(void)
{
    int i;
     //config
    ANSELH=0;
    ANSEL=0;
    TRISA=0xFF;
    TRISB=0x0;
Delay10TCY(20);
    PORTB=0x0;
    for(;;){
        if(RA0 == 1){
            PORTB=0x0;
        }else{
            PORTB=1;
            for(i=0;i<=4;i++){
                PORTB=PORTB<<1;
                __delay_ms(1000);
           
            }
        }
    }



}


Y meda este error:
Código: [Seleccionar]
:: warning: Omniscient Code Generation not available in Free mode
:0: error: undefined symbol:
        _Delay10TCY(dist/default/production\tuto_C18.X.production.obj)
(908) exit status = 1
make[2]: *** [dist/default/production/tuto_C18.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `C:/Users/Limbo/MPLABXProjects/tuto_C18.X'
make[1]: Leaving directory `C:/Users/Limbo/MPLABXProjects/tuto_C18.X'

BUILD FAILED (exit value 2, total time: 5s)

Me tiene loco, estoy usando _delay y __delay_ms, pero quiero saber porque falla eso... :5]
Gracias.
Saludos.

Hola ...si es un pic 16f819 ..los pragma estan mal....deberian estar asi

#pragma config FOSC = INTOSCCLK // Oscillator Selection bits (INTRC oscillator; CLKO function on RA6/OSC2/CLKO pin and port I/O function on RA7/OSC1/CLKI pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF      // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital I/O, MCLR internally tied to VDD)
#pragma config BOREN = OFF      // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF        // Low-Voltage Programming Enable bit (RB3/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB2      // CCP1 Pin Selection bit (CCP1 function on RB2)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

Fijate que en mplab podes definirlos desde windows/pics memori view / configuration bits

una vez que lo hiciste apretas el boton generar source code to output  y listo copias y pegas
 


Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Delay10TCY() No me funciona en XC8
« Respuesta #2 en: 20 de Junio de 2013, 15:18:10 »
Hace otra cosa ...si queres que te funcionen las subrutinas delay10TCY y las demas ..pega la lib de xc18 delays.h en tu carpeta de trabajo ...
Saludos

Ahhh otra cosa ...fijate bien en anselh y ansel ...ojo ahi

« Última modificación: 20 de Junio de 2013, 15:32:43 por Rseliman »
Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Delay10TCY() No me funciona en XC8
« Respuesta #3 en: 20 de Junio de 2013, 16:08:47 »
Perdon me quede pensando ...estas compilando con c18 o xc8 ???

en xc8 la linea roja o warnings del __delay_ms se saca agregando esta linea ...es un error del xc8

#define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))

Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado Limbo

  • PIC10
  • *
  • Mensajes: 44
Re: Delay10TCY() No me funciona en XC8
« Respuesta #4 en: 20 de Junio de 2013, 19:48:50 »
Curiosamente si compilo el mismo codigo en otro proyecto abierto con un pic de la serie 18, el codigo compila perfecto, la LCD no funciona, pero compila  :D