Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Mplab-X

Status
Not open for further replies.

be80be

Well-Known Member
Can't figure why it's not building just a simple blink code to test out my install xc8
Code:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/burt/MPLABXProjects/test.X'
make  -f nbproject/Makefile-default.mk dist/default/production/test.X.production.hex
make[2]: Entering directory '/home/burt/MPLABXProjects/test.X'
"/opt/microchip/xc8/v1.35/bin/xc8" --pass1  --chip=18F1220 -Q -G  --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"    -obuild/default/production/main.p1  main.c
:: warning: (1459) peripheral library support is missing for the 18F1220
main.c:23: warning: (1385) variable "RB0" is deprecated (declared at main.c:23)
main.c:25: warning: (1385) variable "RB0" is deprecated (declared at main.c:25)
"/opt/microchip/xc8/v1.35/bin/xc8"  --chip=18F1220 -G -mdist/default/production/test.X.production.map  --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"    --memorysummary dist/default/production/memoryfile.xml -odist/default/production/test.X.production.elf  build/default/production/main.p1    
:: warning: (1459) peripheral library support is missing for the 18F1220
:: advisory: (1233) Employing 18F1220 errata work-arounds:
:: advisory: (1234)  * GOTO instruction at reset vector must be preceded by NOP
:: advisory: (1234)  * DAW instruction may improperly clear CARRY bit
:: warning: (1273) Omniscient Code Generation not available in Free mode
main.c:23: warning: (1385) variable "_RB0" is deprecated (declared at /opt/microchip/xc8/v1.35/include/pic18f1220.h:4869)
main.c:25: warning: (1385) variable "_RB0" is deprecated (declared at /opt/microchip/xc8/v1.35/include/pic18f1220.h:4869)
main.c:24: error: (1355) in-line delay argument too large
main.c:26: error: (1355) in-line delay argument too large
Microchip MPLAB XC8 C Compiler (Free Mode) V1.35
Build date: Jul  7 2015
Part Support Version: 1.35
Copyright (C) 2015 Microchip Technology Inc.
License type: Node Configuration

(908) exit status = 1
nbproject/Makefile-default.mk:119: recipe for target 'dist/default/production/test.X.production.hex' failed
make[2]: Leaving directory '/home/burt/MPLABXProjects/test.X'
nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
make[1]: Leaving directory '/home/burt/MPLABXProjects/test.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/test.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)
 
Ok it's the delay_ms that's causing the problem but why is it not using the library for the delay ?
Code:
#define _XTAL_FREQ 8000000

#include <xc.h>
#include <stdio.h>
#include <stdlib.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;
}
I committed out the delay it builds.
 
Thanks I new that lol not really sounds good. I'll try it when I get home
 
:: warning: (1459) peripheral library support is missing for the 18F1220
The peripheral libraries aren't included in the standard compiler download anymore... it's a separate download that you have to install.

PIC18 Legacy Peripheral Libraries v2.00 - Windows
**broken link removed**
 
You can find all the downloads on the RSS Software page https://www.microchip.com/RSS/recent-software.xml

What it's really complaining about is the size of the parameter in the delay call.

The _delay (x) inline function is limited to a max of 3 * 256 * 256 = 196608 instruction cycles,
so that's about 98msecs at 8MHz. Drop it down and it'll probably compile.
 
The _delay (x) inline function is limited to a max of 3 * 256 * 256 = 196608 instruction cycles,
so that's about 98msecs at 8MHz. Drop it down and it'll probably compile.
No! not quite right...

Hi tech used unsigned longs.. I believe the XC8 is built on the exact same compiler... In fact XC.h calls htc.h ..

I frequently use __delay_ms(2000)..
This equates to _delay( 2000 * (20000000 / 4000.0)) or _delay (10000000)

snippet from pic.h
C:
/****************************************************************/
/* Built-in delay routine           */
/****************************************************************/
#pragma intrinsic(_delay)
extern __nonreentrant void _delay(unsigned long);
// NOTE: To use the macros below, YOU must have previously defined _XTAL_FREQ
#define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
#endif
 
I see how it's declared, but there's some internal limit. Try compiling this:
Code:
_delay(4294967295UL);
 
 
Error  [1274] E:\xc8_test\main.c; 49. delay exceeds maximum limit of 197120 cycles
(908) exit status = 1
So I was off by a few instruction cycles.

Tried this:
Code:
 #include <xc.h>
 #define _XTAL_FREQ (20000000UL)
 void main(void)
 {
  __delay_ms(2000);
 }
Error  [1355] E:\xc8_test\main.c; 44. in-line delay argument too large
(908) exit status = 1

What trick do you use to get '__delayms(2000)' with a 20MHz clock?
 
The blink code I used worked at one time. But I see where it was saying its to big. Guess you call delay in a loop now lol. Have to see when I get off work I was just using a one sec delay to blink a led to test my setup.
 
tumbleweed An Ian I tried it the delay_ms doesn't let me use it for more them 90 ms then it errors. So there's no using it for 1000 ms. and 2000 is out too.

But like i said I've used it before but this is on a new install of Mplab on linux debian so have i left something out here.
 
Ah! All is revealed..

I use mplabC18 for all my Pic18 needs.... XC8 for the smaller ones..
I really don't understand this logic!! This is a snippet from the manual!!
Help file said:
An error will result if the delay period requested is not a constant expression or is too
large (approximately 179,200 for PIC18 devices, and 50,659,000 instructions for other
8-bit PIC devices). For very large delays, call this function multiple times.
 
i have liked mplabX so far, auto importing .h's and config bit generators! , but i noticed problems with delayMS as well, i had to write myown delayS sub, and i noted that delay ms only holds an unsigned integer.
 
Thanks all got to love Mplab on Linux so much fun getting started with xc8 old blink code don't work new blink code works after i figured out i had my programmer held in reset. Maybe better place to put osccon setting then my delay but it makes the delay run right but it would work in main too i'm sure.
Code:
void Delay_Seconds(unsigned char s) // nice delay that sets seconds 
{
OSCCON = 0x70;  
unsigned char i,j;
for(j = 0; j < s; j++)
{
for(i = 0; i < 100; i++)__delay_ms(10);
}
}

int main()
{
  ADCON1 = 0b00001111;
  TRISB0 = 0; //RB0 as Output PIN
  while(1)
  {
    RB0 = 1;  // LED ON
      Delay_Seconds(2); // 2 Second Delay
    RB0 = 0;  // LED OFF
      Delay_Seconds(2); // 2 Second Delay
  }
  return 0;
}
 
How do you like mplabX on Linux? I'm still using C18 for just about everything for PIC18 as the Linux version (3.40) is the FULL version and can be updated to use 3.46 libs without too much trouble if you need to run legacy code under Linux..
**broken link removed**

**broken link removed**
You can use 7z to unarchive this, then untar it in a new directory then use mplabx (tools:embedded:build tools:add) to add it as a new compiler.
 
Last edited:
Thanks for links. I like how it works on Linux not real happy with xc8. The real problem was the delay they don't let you have a sec on pic18 but I wouldn't of had that problem on the pic 16 lol that I wrote code for years ago. I really want to use jalv2 but you have to run jaledit on wine. What ever happen to boostc. Anyway I could just use asm for what I want to do.
 
The problem with xc8 is that its sometimes too smart and gets in the way for simple embedded 8bit programming on the front-end. Having a delay_ms function that won't take a long value to max count is stupid. It's better to use a timer for long counts but if doing simple timing hacks requires jumping loops for a "Hello world!" blinking LED, I don't like it.
 
I'm OK with the delay not working but there's over 500 pages of how to use xc8 and you got to read it two times to figure out that half of it not wrote to understand what you need to do. Microchip would be a lot better if they gave a fully working xc8 that people like use could use to help sale the chips. Oh and there wouldn't of been a ardunio with a avr in it it would of been a pic lol and the world would be using lots more pic chips. Guess the sales of xc8 is that good lol
 
I'm OK with the delay not working but there's over 500 pages of how to use xc8 and you got to read it two times to figure out that half of it not wrote to understand what you need to do. Microchip would be a lot better if they gave a fully working xc8 that people like use could use to help sale the chips. Oh and there wouldn't of been a ardunio with a avr in it it would of been a pic lol and the world would be using lots more pic chips. Guess the sales of xc8 is that good lol

Microchip is not hurting for chip sales so while the Ardunio market is nice it's a very small slice of the larger OEM pie. Tools have always been a problem with hardware companies, XC8 is great in the PRO version but the free versions just suck. I'll take a look at JAL (Just Another Language, version 2) but like you I'm mainly a Linux based (C) environment development guy.
 
I'm sure they sale chips but it would be even better to to open up the xc as free and sale lots more chips. That's not even because I want it for free. More people would jump on it and make it better.
But they want to sale programmers that get outdated and need new ones software. That needs fixing. $995 for xc8 is out of a hobby price range. What's got me is I full with so much stuff I can't buy everything out there and now a lot off it works on Linux better then windows. Never used windows for much till I started pic programming. But I love the way on my Linux box I can dig in and do what ever I like without buying more tools. IPhone something to buy windows same thing. WiFi chips like esp8266 theres new tool thank god I don't have to buy them all lol.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top