Problem with PIC161519 / XC8


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2016
    Posts
    1

    Default Problem with PIC161519 / XC8

    Hi every one,

    First, please excuse my bad english (I'm from France).





    I'm a beginner on MPLAB X IDE 3.26 and I would like to make a little program allowing to light a LED PORT B0 but I get errors that I do not understand. Here is my program named TextXC8 :


    TestXC8.h :


    /*
    * File: TestXC8.h
    * Author: dymentional
    *
    * Created on April 25, 2016, 1:53 PM
    */



    // PIC16F1519 Configuration Bit Settings

    // 'C' source line config statements

    #include <xc.h>
    #include <xc.inc>
    #include "xc8debug.h"
    #include "TestXC8.h"

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

    // CONFIG1
    #pragma config FOSC = INTOSC // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
    #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
    #pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
    #pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
    #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
    #pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)
    #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
    #pragma config IESO = ON // Internal/External Switchover (Internal/External Switchover mode is enabled)
    #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)

    // CONFIG2
    #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
    #pragma config VCAPEN = OFF // Voltage Regulator Capacitor Enable bit (VCAP pin function disabled)
    #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
    #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
    #pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled)
    #pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)


    #define _XTAL_FREQ 8000000





    TestXC8.c :


    /*
    * File: TestXC8.c
    * Author: Dymentional
    *
    * Created on April 25, 2016, 2:11 PM
    */



    #include <xc.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <pic16f1519.h>
    #include <htc.h>


    #define led1 PORTB.F0 //RB0

    /*
    *
    */
    int main(int argc, char** argv) {

    OSCCON = 0x72; //Configure le registre OSCCON en oscillateur interne
    PORTB = 0b11111111; //Init des pattes du µcontroleur
    TRISB = 0b11111110; //Bit 0 du Port B en sortie


    /*while (1)
    {
    LATBbits.LATB0 = ~LATBbits.LATB0; //crée une boucle de 1s
    for (int countDelay=0; countDelay <20; countDelay ++)__delay_ms(50);
    }
    }*/he
    while(1)n I
    {
    //Delay ~1 second (8MHz Internal Clock)
    __delay_ms(8000000); //specify clock cycles directly
    }

    }


    And when I build the project :


    CLEAN SUCCESSFUL (total time: 302ms)
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory '/home/colin/microchip/colin/TestXC8.X'
    make -f nbproject/Makefile-default.mk dist/default/production/TestXC8.X.production.hex
    make[2]: Entering directory '/home/colin/microchip/colin/TestXC8.X'
    "/opt/microchip/xc8/v1.37/bin/xc8" --pass1 --chip=16F1519 -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=std -P -N255 --warn=-3 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/TestXC8.p1 TestXC8.c
    make[2]: *** [build/default/production/TestXC8.p1] Error 1
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2
    TestXC8.c:39: error: (192) undefined identifier "_XTAL_FREQ"
    (908) exit status = 1
    nbproject/Makefile-default.mk:94: recipe for target 'build/default/production/TestXC8.p1' failed
    make[2]: Leaving directory '/home/colin/microchip/colin/TestXC8.X'
    nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
    make[1]: Leaving directory '/home/colin/microchip/colin/TestXC8.X'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

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



    What can I do ?

    Thank you very much !


    Dymentional

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: Problem with PIC161519 / XC8

    This looks like C.

    This is a Pic BASIC Pro forum.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Problem with PIC161519 / XC8

    This is not a "C" forum. However there are some people here with "C" background... I am not one of them...
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Problem with PIC161519 / XC8

    i'm a bit rusty on xc8 and as dave says this is a pbp forum not C
    but for what its worth
    Code:
    /* 
     * File: TestXC8.c
     * Author: Dymentional
     *
     * Created on April 25, 2016, 2:11 PM
     */
    
    
    
     #include <xc.h>
     #include <stdio.h>
     #include <stdlib.h>
     #include <pic16f1519.h>  not sure this is going to help , if project set up correctly in mplabx this is unnecessary
     #include <htc.h>
    #include <TestXC8.h> // will help
    
     #define led1 PORTB.F0 //RB0   ?????????????????
    
     /*
     * 
     */
     int main(int argc, char** argv) {
    
     OSCCON = 0x72; //Configure le registre OSCCON en oscillateur interne
     PORTB = 0b11111111; //Init des pattes du µcontroleur
     TRISB = 0b11111110; //Bit 0 du Port B en sortie
    
    
     /*while (1)
     { 
     LATBbits.LATB0 = ~LATBbits.LATB0; //crée une boucle de 1s
     for (int countDelay=0; countDelay <20; countDelay ++)__delay_ms(50);
     } 
     }*/he
     while(1)n I 
     {
     //Delay ~1 second (8MHz Internal Clock)
     __delay_ms(8000000); //specify clock cycles directly   no way 
    // delay_ms is delay milliseconds not clockcycles
    // the function prototype uses ints  which limits range to much less than 8000000,from memory  its less than 1000 ms depending on clock }
    
     }

  5. #5
    Join Date
    Oct 2014
    Location
    Lagos Nigeria
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Problem with PIC161519 / XC8

    Hi Dymentional, as has already been stated this might not be the right place but being familiar with xc8; I think you need to place the following

    #define _XTAL_FREQ 8000000 // OSC FREQUENCY IN Hz

    at the top of the code. Then
    __delay_ms(1000) // DELAY FOR 1 SECOND

Similar Threads

  1. Replies: 8
    Last Post: - 11th November 2004, 21:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts