Jump to content
Ian Harris

Error Compiling To 18f14k50

Recommended Posts

Hi guys,

 

Having some fun with the new 18f14k50 chip - when compiling to this target, the compiler fails to compile, despite compiling fine for another target (eg 18f26k20). The failure lines don't appear to make much sense, sometimes it's a pragma line (as in this bootloader):

 

Building...
BoostC Optimizing C Compiler Version 6.97 (for PIC18 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2010 Pavel Baranov
Copyright(C) 2004-2010 David Hobday

Licensed to Ian Harris under Single user Pro License for 1 node(s)
Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited


..\BoostBloader.c
C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\chipdefs.h(271): WARNING: Compiling for PIC18F14K50
C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\chipdefs.h(281): WARNING: Did you set -rb 15780 in Settings | Options | Linker?
C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\configbits.h(116): WARNING: config for 18f14k50
C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\configbits.h(121): WARNING: External crystal, PLL allowed
C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\BoostBloader.c(85): WARNING: high speed uart disabled
C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\BoostBloader.c(262): WARNING: led off

failure
C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\chipdefs.h(288): error:  failure
"C:\Program Files (x86)\SourceBoost\boostc_pic18.exe" ..\BoostBloader.c -t PIC18F14K50 -W2 -Oa -Su -I "..\..\pic_pack_lib;..\" -obj ".\" 
Exit code was 1.
Removing target: .\BoostBloader.obj
Failed to locate output file 'C:\Users\iharris\Documents\My Dropbox\Programming\boostbloader\18f14k50\18f14k50_12Mhz_48Mhz_PLL.hex'
Done

Failed

 

The line in question:

 

 

#ifdef _PIC18F14K50
#warning "Compiling for PIC18F14K50"
#define pic_mem_16k
#define pic_18
#define erase_before_write
#define min_erase_chunk 64
#define max_write_chunk	16
#define BLOADER_START 0x3da4
#define BLOADER_UPPER 0x00
#define BLOADER_START_HIGH 0x3d
#define BLOADER_START_LOW  0xa4
#warning "Did you set -rb 15780 in Settings | Options | Linker?"
#define MOVED_BVECTOR_START 0x3d78
#define MOVED_BVECTOR_UPPER 0x00
#define MOVED_BVECTOR_HIGH  0x3d
#define MOVED_BVECTOR_LOW   0x78
#define JUMP_TO_BVECTOR1 0xefbc
#define JUMP_TO_BVECTOR2 0xf01e
// The next line is the "problem":
#pragma DATA 0x0000, 0xd2, 0xef, 0x1e, 0xf0
#define JUMP_TO_BLOADER1 0xef
#define JUMP_TO_BLOADER2 0xd2
#define JUMP_TO_BLOADER3 0xf0
#define JUMP_TO_BLOADER4 0x1e
//#define SERIAL_TRIS_SETUP()
#endif

 

Sometimes it's just a function definition

 

"C:\Program Files (x86)\SourceBoost\boostc_pic18.exe" -t PIC18F14K50 -W2 -I "..\..\pic_pack_lib" -obj ".\"  ..\..\pic_pack_lib\pic_serial.c ..\..\pic_pack_lib\pic_utils.c ..\..\pic_pack_lib\i2c.c ..\..\pic_pack_lib\tmp75.c ..\..\pic_pack_lib\m41t81s.c ..\..\pic_pack_lib\mrf24j40.c ..\..\pic_pack_lib\spi_hw.c ..\..\pic_pack_lib\its_mode2.c ..\..\pic_pack_lib\wpan.c ..\..\pic_pack_lib\its_common.c ..\..\pic_pack_lib\pic_timer.c ..\..\pic_pack_lib\draw\drv_sure_6432.c ..\..\pic_pack_lib\draw\draw.c ..\..\pic_pack_lib\draw\draw_font_picpack_5x7.c ..\..\pic_pack_lib\draw\draw_screen_buffer.c ..\..\pic_pack_lib\sure_6432.c ..\..\pic_pack_lib\pic_tick.c ..\..\pic_pack_lib\pic_timer1.c ea_mega_clock.c ..\..\pic_pack_lib\pic_term.c ..\..\pic_pack_lib\platform_leds.c

BoostC Optimizing C Compiler Version 6.97 (for PIC18 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2010 Pavel Baranov
Copyright(C) 2004-2010 David Hobday

Licensed to Ian Harris under Single user Pro License for 1 node(s)
Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited


..\..\pic_pack_lib\pic_serial.c
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\pic_serial.c(97): WARNING: You must set tris bits for serial use yourself, I don't know your pic
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\pic_serial.c(98): WARNING: Please send your tris bits in so they can be included in the library
..\..\pic_pack_lib\pic_utils.c
..\..\pic_pack_lib\i2c.c
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\i2c.c(164:12): warning: local variable 'in_byte' may be used uninitialized
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\i2c.c(165): warning: conversion from 'unsigned char' to 'bit', possible loss of data
..\..\pic_pack_lib\tmp75.c
..\..\pic_pack_lib\m41t81s.c
..\..\pic_pack_lib\mrf24j40.c
..\..\pic_pack_lib\spi_hw.c
..\..\pic_pack_lib\its_mode2.c
..\..\pic_pack_lib\wpan.c
..\..\pic_pack_lib\its_common.c
..\..\pic_pack_lib\pic_timer.c
..\..\pic_pack_lib\draw\drv_sure_6432.c
..\..\pic_pack_lib\draw\draw_screen_buffer.h(40): WARNING: 4 draw buffers
..\..\pic_pack_lib\draw\draw.c
..\..\pic_pack_lib\draw\draw_screen_buffer.h(40): WARNING: 4 draw buffers
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\draw\draw.c(317): warning: conversion from 'signed int' to 'unsigned char', possible loss of data
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\draw\draw.c(320): warning: conversion from 'signed int' to 'unsigned char', possible loss of data
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\draw\draw.c(328): warning: conversion from 'signed int' to 'unsigned char', possible loss of data
C:\Users\iharris\Documents\My Dropbox\Programming\pic_pack_lib\draw\draw.c(331): warning: conversion from 'signed int' to 'unsigned char', possible loss of data
..\..\pic_pack_lib\draw\draw_font_picpack_5x7.c
..\..\pic_pack_lib\draw\draw_screen_buffer.c
..\..\pic_pack_lib\draw\draw_screen_buffer.h(40): WARNING: 4 draw buffers
..\..\pic_pack_lib\sure_6432.c
..\..\pic_pack_lib\pic_tick.c
..\..\pic_pack_lib\pic_timer1.c
ea_mega_clock.c
..\..\pic_pack_lib\draw\draw_screen_buffer.h(40): WARNING: 4 draw buffers
C:\Users\iharris\Documents\My Dropbox\Programming\Projects\ea_mega_clock\ea_mega_clock.c(117): error: general error
..\..\pic_pack_lib\pic_term.c
C:\Users\iharris\Documents\My Dropbox\Programming\Projects\ea_mega_clock\ea_mega_clock.c(117): error:  failure

failure
Failed to locate output file '.\ea_mega_clock.obj'
Done

Failed

 

The line in question is "void configure_system" (117):

 

void timer_1_callback() {
// refresh display from draw buffer
drv_refresh();	
}



// configure_system
//
// Get the pic ready for everything we want to do

void configure_system() {

uns8 my_ea[8] = { 0, 0, 0, 0, 0, 0, 0, 5 };		

kill_interrupts();	// turn off interrupts just in case

turn_analog_inputs_off();	// kill those pesky analogue inputs

// serial setup ----------------------------
serial_setup(SPBRG_115200);	// set serial port up for 115.2k

term_init();	// initialise terminal

 

Both these projects compile fine if another target is chosen (eg 18f2620).

 

Latest sourceboost RC, pulled from the website an hour ago.

 

kind regards

Ian.

Share this post


Link to post
Share on other sites

Just a note for the others, thanks to the excellent Sourceboost support, the problem turned out to be:

 

 

#ifdef _PIC18F26K20
#define turn_analog_inputs_off() clear_bit(adcon0, ADON);
#endif


#ifndef turn_analog_inputs_off()
#define turn_analog_inputs_off() \
	#warning "!!! - See pic_utils.h for turning off analog inputs on your pic"
#endif

 

Since I was using a new PIC, the code was designed to alert me that there was no turn_analog_inputs_off() routine by issuing a warning if it was used. Turns out that creating a #define using the #warning (which is a preprocessor function) within a #define is of dubious legality. If you get your head around it, you can imagine that the preprocessor runs through, doesn't see turn_analog_inputs_off() as defined, so it #defines it as a #warning - but at that point the preprocessors job is done, and then the compiler ends up seeing the code #warning, which of course it doesn't know what to do with.

 

At least, that's my take.

 

Solution is to issue a warning or error regardless of whether the routine is used.

 

#ifdef _PIC16F88
#define turn_analog_inputs_off() ansel = 0
#elif _PIC16F876A
#define turn_analog_inputs_off() adcon1 = 6
#elif _PIC16F877A // Note - 16F877a unverified
#define turn_analog_inputs_off() adcon1 = 6
#elif _PIC18F4520
#define turn_analog_inputs_off() adcon1 = 15
#elif _PIC18F452
#define turn_analog_inputs_off() adcon1 = 6
#elif _PIC18F2620
#define turn_analog_inputs_off() adcon1 = 15
#elif _PIC18F4550
#define turn_analog_inputs_off() adcon1 = 15
#elif _PIC18F26K20
#define turn_analog_inputs_off() ansel = 0; anselh = 0
#elif _PIC18F14K50
#define turn_analog_inputs_off() ansel = 0; anselh = 0
#else
#warning "See pic_utils.h for turning off analog inputs on your pic. Analog inputs will not be turned off if you use turn_analog_inputs_off()"
	#define turn_analog_inputs_off()
#endif

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...