CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to combine two hex? [Solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

How to combine two hex? [Solved]
PostPosted: Mon Sep 12, 2022 8:19 pm     Reply with quote

I think I asked this before but can't find the thread.

I have an USB bootloader and want to combine it with an already generated HEX.

The bootloader start at 0x0000 and the main program at 0x3000.

The device is a PIC16F87J50.

I have this as the bootloader code
Code:

#include <18F67J50.h>
#fuses INTRC_PLL,PLL2,NOCPUDIV,NOIESO,NOFCMEN,STVREN,CCP2E7,NOWDT,WDT2048,PROTECT //WDT8Seg.

#use delay(clock=48M)
#use rs232(UART1,stream=GSM,NOINIT)

#use fast_io(ALL)

#define _BOOTLOADER
#define LOADER_END 0x2FFF
#include <bootloader.h>


And at the main program
Code:
#use delay(clock=48M)

#define BOOTLOADER_AT_START 0x3000
#define LOADER_END 0x2FFF
#include <bootloader.h>


Now I want to compile the bootloader and add the HEX generated by the main program to the final HEX.
_________________
Electric Blue
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Mon Sep 12, 2022 9:45 pm     Reply with quote

I just solved!
If somebody needs to do the same can use this code line as example.
Code:
#import (FILE=D:\Projects\BootHex\GPS_100_V19-1-1\Standard\GPS_100_V19D.hex,HEX,RANGE=0x3000:0x1FFFB)


Is pretty simple, the main code to import starts at 0x3000, so everything before that address is ignored and the compiler doesn't complain about the 0x0000 to 0x2FFF being used even when the HEX only has NOPs.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Tue Sep 13, 2022 3:28 am     Reply with quote

A quick search on the forum would have found solutions to this.
A few decades ago, the easiest way was to import the bootloader, then the
main program with MPLAB, and export the final file.

Then the #import route became available.

With this is is best to have #FUSES NONE in the main code. Otherwise
you may get a warning because these are present in both files.
Also remember that each program has to do #PIN SELECT setups if
you are using a chip with PPS, so NOPPS1WAY becomes essential.
[url]
http://www.ccsinfo.com/forum/viewtopic.php?t=55747&highlight=combine%2A+files+bootloader
[/url]
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group