• AVR Freaks

Hot!Absolute Beginner question

Author
sabahan
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2016/03/20 20:31:24
  • Location: 0
  • Status: offline
2020/06/19 01:06:33 (permalink)
0

Absolute Beginner question

I just started learning XC8,using MPLab X to compile and are following the code of a book bought from Amazon,it just to turn on a LED using PIC16F1717,the code is as follow
 
void initmain(){
internal_16();
TRISDbits.TRISD1 = 0;
}
void main(void){
initMain();

while(1);
LATDbits.LATD1 = 1;
return;
 
 
The error Message:
:: warning: (1273) Omniscient Code Generation not available in Free mode
16F1717_Intenal.c:12: warning: (520) function "_internal_32" is never called
16F1717_Intenal.c:23: warning: (520) function "_Internal_16" is never called
16F1717_Intenal.c:33: warning: (520) function "_Internal_8" is never called
16F1717_Intenal.c:43: warning: (520) function "_internal_4" is never called
16F1717_Intenal.c:53: warning: (520) function "_Internal_2" is never called
16F1717_Intenal.c:64: warning: (520) function "_Internal_1" is never called
16F1717_Intenal.c:75: warning: (520) function "_Internal_31" is never called
main.c:10: warning: (520) function "_initmain" is never called
:0: error: (499) undefined symbol:
_initMain(dist/default/production\First_on_PIC16F1717.X.production.obj)
make[2]: *** [dist/default/production/First_on_PIC16F1717.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
(908) exit status = 1
nbproject/Makefile-default.mk:147: recipe for target 'dist/default/production/First_on_PIC16F1717.X.production.hex' failed
make[2]: Leaving directory 'D:/XC8 Files/First on PIC16F1717.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/XC8 Files/First on PIC16F1717.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 916ms)
 
 
 
 
What have I did wrong?
#1

5 Replies Related Threads

    mbrowning
    USNA79
    • Total Posts : 1773
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: online
    Re: Absolute Beginner question 2020/06/19 01:23:12 (permalink)
    +2 (2)
    You are being sloppy with spelling. “initmain” is not the same as “initMain” for example. Same issue with “internal” apparently though you didn’t show us all your source code.

    Other issues- empty parameter list for initmain, no config bits, “while(1);” endless loop will never advance to the next line because of the semicolon (also missing brackets around the code you want to execute endlessly), and in my opinion it’s bad style to have “return” at the end of main when you should never allow main to return
    post edited by mbrowning - 2020/06/19 01:25:28
    #2
    ric
    Super Member
    • Total Posts : 27652
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Absolute Beginner question 2020/06/19 01:49:56 (permalink)
    +2 (2)
    +1
    I'd take a guess that sabahan is coming from a language where upper/lower case doesn't matter (e.g. BASIC)
    Here's a few improvements
     
    // PIC16F1717 Configuration Bit Settings

    // 'C' source line config statements

    // CONFIG1
    #pragma config FOSC = INTOSC    // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin)
    #pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
    #pragma config PWRTE = ON       // Power-up Timer Enable (PWRT enabled)
    #pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
    #pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
    #pragma config BOREN = ON       // Brown-out Reset Enable (Brown-out Reset enabled)
    #pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
    #pragma config IESO = OFF       // Internal/External Switchover Mode (Internal/External Switchover Mode is disabled)
    #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 PPS1WAY = OFF    // Peripheral Pin Select one-way control (The PPSLOCK bit can be set and cleared repeatedly by software)
    #pragma config ZCDDIS = ON      // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR and can be enabled with ZCDSEN bit.)
    #pragma config PLLEN = OFF      // Phase Lock Loop enable (4x PLL is enabled when software sets the SPLLEN bit)
    #pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
    #pragma config BORV = HI        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), high 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)

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

    #include <xc.h>

    void initMain(void){
      //internal_16();  //function removed, as it does not exist.
      TRISDbits.TRISD1 = 0;    // switch RD1 to output
    }
     

    void main(void){
       initMain();

      while(1) {
        LATDbits.LATD1 = 1;
     
      }
    }

     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    sabahan
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2016/03/20 20:31:24
    • Location: 0
    • Status: offline
    Re: Absolute Beginner question 2020/06/19 01:51:25 (permalink)
    0
    Thank You,it really a very fundamental mistake,problem solved,all are spelling error
    #4
    RISC
    Super Member
    • Total Posts : 5757
    • Reward points : 0
    • Status: offline
    Re: Absolute Beginner question 2020/06/19 09:09:38 (permalink)
    0
    Hi,
    This website will help you getting started : https://microchipdeveloper.com
    And many examples also here : https://mplabxpress.microchip.com/mplabcloud/example
    A simple board to use PIC16F1717 : HPC Curiosity
    Regards
     
    #5
    WeHongKongers
    Super Member
    • Total Posts : 227
    • Reward points : 0
    • Status: offline
    Re: Absolute Beginner question 2020/06/19 10:03:14 (permalink)
    0
    He is from DOS/Windows.
     
    I had no problem with XC as I also use Linux.  Smile: Smile
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5