unable to build my program

(instructions, reset, WDT, specifications...) PIC12F6xx, PIC16Fxxx, PIC16F6x, PIC16F7x

unable to build my program

Postby newuserrrr » Sun Apr 29, 2018 5:59 pm

Hi I am using PIC16F877A with MPLABX IDE and XC8 compiler.
Here is the program that I am trying to build


Code: Select all
/*
 * File:   LED.c
 * Author: Vivek
 *
 * Created on April 29, 2018, 8:40 PM
 */

#include <stdio.h>
#include <stdlib.h>
// PIC16F877A Configuration Bit Settings

// 'C' source line config statements

// CONFIG
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = ON        // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF        // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

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

#include <xc.h>
/*
 *
 */
int main()
{
  TRISB0 = 0; //RB0 as Output PIN
  while(1)
  {
    RB0 = 1;  // LED ON
    __delay_ms(1000);// 1 Second Delay
    RB0 = 0;  // LED OFF
    __delay_ms(1000); // 1 Second Delay
  }
  return 0;
}


These are the errors that I am getting


Code: Select all
CLEAN SUCCESSFUL (total time: 32ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/Vivek/MPLABXProjects/LED blink.X'
make  -f nbproject/Makefile-default.mk dist/default/production/LED_blink.X.production.hex
make[2]: Entering directory 'C:/Users/Vivek/MPLABXProjects/LED blink.X'
"C:\Program Files (x86)\Microchip\xc8\v1.45\bin\xc8.exe" --pass1  --chip=16F877A -Q -G  --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default  --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/LED.p1  LED.c
Warning: xclm.conf did not indicate a license directory
  Using current working directory to look for and create licenses
LED.c:37: error: (192) undefined identifier "_XTAL_FREQ"
make[2]: *** [build/default/production/LED.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
(908) exit status = 1
nbproject/Makefile-default.mk:106: recipe for target 'build/default/production/LED.p1' failed
make[2]: Leaving directory 'C:/Users/Vivek/MPLABXProjects/LED blink.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/Vivek/MPLABXProjects/LED blink.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 620ms)


I am using Windows OS

I am new to PIC, needs help.
newuserrrr
 
Posts: 1
Joined: Sun Apr 29, 2018 5:26 pm

Re: unable to build my program

Postby vloki » Sun Apr 29, 2018 7:13 pm

You have to define _XTAL_FREQ to use __delay_ms()
For details best view the user guide of the compiler...
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: unable to build my program

Postby ric » Tue May 01, 2018 4:31 am

Page 65:
3.5.11 How Can I Implement a Delay in My Code?

Page 349:
Documentation for "_delay_ms" macro
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products


Return to 14-Bit Core

Who is online

Users browsing this forum: No registered users and 11 guests

cron