Cart Contact NSDSP Home

hex_map_merge

This function merges data from two Hex Map objects into a single Hex Map.

Syntax

hex_map_t hex_map_merge(
        hex_map_t         map_a,
        hex_map_t         map_b
);

Parameters

map_a - a reference to the first Hex Map Object. Must be normalized.

map_b - a reference to the second Hex Map Object. Must be normalized.

Return

The function returns the new Hex Map object or NULL if operation fails.

Notes

If there are overlapping blocks, the data coming from map_b will overwrite the data from map_a.

Example

Dual partition dsPIC33 microcontrollers may have two separate partitions, and each partition may be programmed with its own application. You can create a combined Hex file on the fly:

hex_map_t LoadCombinedHexFile(
  mcu_t mcu,
  char* File1,
  char* File2,
  char* err)
{
  hex_map_t hm, hm1, hm2;
  hex_block_t b;
  int r;

  // load first HEX file
  hm1 = hex_map_read(File1,err);
  if (!hm1) return NULL;

  // load second HEX file
  hm2 = hex_map_read(File2,err);
  if (!hm2) {
    hex_map_free(hm1);
    return NULL;
  }

  // move the second HEX file into inactive partition
  b = hex_map_first_block(hm2);
  while (b) {
    b->addr |= 0x00800000;
    b = hex_block_next(b);
  }

  // merge the files
  hm = hex_map_merge(hm1,hm2);
  hex_map_free(hm1);
  hex_map_free(hm2);

  // mark the Hex Map object as partitioned
  if (hm) hex_map_partition(hm,mcu);

  return hm;
}

Similarly, you can merge bootloader and application Hex files.

 

Minimum library version - 163

Northern Software Home NSDSP Contact Us Purchase/View Cart

© 2007-2025 Northern Software Inc. All Rights Reserved.